Skip to content

Commit

Permalink
Handle special chars in password
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed May 31, 2024
1 parent 344df1c commit 09c33c8
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit 09c33c8

Please sign in to comment.