BLOG-45 fix: percent encode the database password
Some checks failed
Frontend CI / build (push) Failing after 54s

This commit is contained in:
SquidSpirit 2025-07-24 13:11:44 +08:00
parent 23c312a9db
commit 2e42391918
6 changed files with 10 additions and 7 deletions

1
backend/Cargo.lock generated
View File

@ -1789,6 +1789,7 @@ dependencies = [
"actix-web",
"dotenv",
"env_logger",
"percent-encoding",
"post",
"sqlx",
]

View File

@ -14,6 +14,7 @@ dotenv = "0.15.0"
env_logger = "0.11.8"
futures = "0.3.31"
log = "0.4.27"
percent-encoding = "2.3.1"
serde = { version = "1.0.219", features = ["derive"] }
sqlx = { version = "0.8.5", features = [
"chrono",

View File

@ -7,6 +7,7 @@ edition.workspace = true
actix-web.workspace = true
dotenv.workspace = true
env_logger.workspace = true
percent-encoding.workspace = true
sqlx.workspace = true
post.workspace = true

View File

@ -34,9 +34,13 @@ async fn init_database() -> Pool<Postgres> {
let user = env::var("DATABASE_USER").unwrap_or_else(|_| "postgres".to_string());
let password = env::var("DATABASE_PASSWORD").unwrap_or_else(|_| "".to_string());
let dbname = env::var("DATABASE_NAME").unwrap_or_else(|_| "postgres".to_string());
let encoded_password =
percent_encoding::utf8_percent_encode(&password, percent_encoding::NON_ALPHANUMERIC)
.to_string();
let database_url = format!(
"postgres://{}:{}@{}:{}/{}",
user, password, host, port, dbname
user, encoded_password, host, port, dbname
);
let db_pool = PgPoolOptions::new()

View File

@ -5,8 +5,8 @@
const { postInfo }: { postInfo: PostInfoViewModel } = $props();
</script>
<div class="flex flex-col gap-y-4 pt-9 md:pt-20">
<div class="flex flex-row gap-2">
<div class="flex flex-col pt-9 md:pt-20">
<div class="pb-4 flex flex-row gap-2">
{#each postInfo.labels as label (label.id)}
<Label {label} />
{/each}

View File

@ -1,7 +1,3 @@
<script lang="ts">
import { page } from '$app/state';
</script>
<div
class="mx-auto flex min-h-content-height max-w-screen-xl flex-col items-center justify-center px-4 md:px-6"
>