Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle special chars in password #75

Merged
merged 1 commit into from
May 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ impl diesel::r2d2::CustomizeConnection<SqliteConnection, diesel::r2d2::Error>
{
fn on_acquire(&self, conn: &mut SqliteConnection) -> Result<(), diesel::r2d2::Error> {
(|| {
// FIXME: Special characters might fuck up
conn.batch_execute(&format!("PRAGMA key={}", self.key))?;
let password = self.key.as_str().replace("'", "''");
conn.batch_execute(&format!("PRAGMA key='{password}'"))?;
if self.enable_wal {
conn.batch_execute("PRAGMA journal_mode = WAL; PRAGMA synchronous = NORMAL;")?;
}
Expand Down Expand Up @@ -415,7 +415,7 @@ mod tests {
use std::str::FromStr;
use tempdir::TempDir;

const DEFAULT_PASSWORD: &str = "test";
const DEFAULT_PASSWORD: &str = "p.a$$w0rd!'x";
const FEDERATION_ID: &str = "c8d423964c7ad944d30f57359b6e5b260e211dcfdb945140e28d4df51fd572d2";

fn setup_test_db() -> Arc<SQLConnection> {
Expand Down