diff --git a/Cargo.lock b/Cargo.lock index 43a606a..60591b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,9 +24,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.95" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" [[package]] name = "base64" @@ -467,14 +467,14 @@ checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.90", ] [[package]] name = "serde_json" -version = "1.0.134" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -495,7 +495,7 @@ dependencies = [ [[package]] name = "signal-decrypt-backup-wasm" -version = "0.1.1" +version = "0.1.0" dependencies = [ "aes", "base64", @@ -535,9 +535,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.91" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53cbcb5a243bd33b7858b1d7f4aca2153490815872d86d955d6ea29f743c035" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -596,7 +596,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.90", "wasm-bindgen-shared", ] @@ -618,7 +618,7 @@ checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.91", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index 90fc3b5..deb7488 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "signal-decrypt-backup-wasm" -version = "0.1.1" +version = "0.1.0" edition = "2021" description = "Get the raw database from your Signal backup. Written for webassembly" repository = "https://git.duskflower.dev/duskflower/signal-decrypt-backup-wasm" diff --git a/build.sh b/build.sh deleted file mode 100755 index 8f41923..0000000 --- a/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -wasm-pack build --scope duskflower --release --target bundler -jq '. |= . + {"publishConfig": {"registry": "https://git.duskflower.dev/api/packages/duskflower/npm/"}}' pkg/package.json > pkg/package.json.tmp && mv pkg/package.json.tmp pkg/package.json diff --git a/src/lib.rs b/src/lib.rs index 2eff063..62e0298 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -158,33 +158,27 @@ fn sql_parameter_to_string( fn process_parameter_placeholders(sql: &str, params: &[String]) -> Result { let mut result = sql.to_string(); let mut param_index = 0; - let mut str_index = 0; - while str_index < result.len() { - // Find the next placeholder - let next_placeholder = result[str_index..].find('?'); + while param_index < params.len() { + let rest = &result[param_index..]; + + // Find the next placeholders + // signal backups only use the standard type and not indexed or other ones + let next_placeholder = rest.find('?').map(|i| (i, 1)); // ? style match next_placeholder { - Some(pos) => { - // Calculate the actual position in the result string - let actual_pos = str_index + pos; - - // Check if we have enough parameters - if param_index >= params.len() { + Some((pos, len)) => { + // Replace the placeholder with the parameter value + if param_index < params.len() { + let before = &result[..param_index + pos]; + let after = &result[param_index + pos + len..]; + result = format!("{}{}{}", before, params[param_index], after); + param_index += 1; + } else { return Err(JsValue::from_str( "Not enough parameters provided for SQL statement", )); } - - // Replace the placeholder with the parameter value - let before = &result[..actual_pos]; - let after = &result[actual_pos + 1..]; // Skip the placeholder '?' - - // Update str_index to the new position after the replacement - str_index = before.len() + params[param_index].len(); - - result = format!("{}{}{}", before, params[param_index], after); - param_index += 1; } None => { // No more placeholders found