Skip to content

Commit 9004372

Browse files
fixup(source-edit): validate URL on CLI update + drop dead binding
- CLI source update now runs validate_caldav_url on the new URL, mirroring the web handler. Closes a parity gap where the web path rejected private IPs but the CLI happily accepted them. - Stop SELECT-ing and binding current_password_enc in the no-rotation arm; it was only used for a `let _ =` discard. Use a 4-tuple destructure instead. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4d55c06 commit 9004372

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

src/commands/source.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,24 @@ pub async fn run(pool: &SqlitePool, key: &[u8; 32], cmd: SourceCommands) -> Resu
184184
username,
185185
password,
186186
} => {
187-
let existing: Option<(String, String, String, String, String)> = sqlx::query_as(
188-
"SELECT id, name, url, username, password_enc FROM caldav_sources WHERE id LIKE ? || '%'",
187+
let existing: Option<(String, String, String, String)> = sqlx::query_as(
188+
"SELECT id, name, url, username FROM caldav_sources WHERE id LIKE ? || '%'",
189189
)
190190
.bind(&id)
191191
.fetch_optional(pool)
192192
.await?;
193193

194-
let (full_id, current_name, current_url, current_username, current_password_enc) =
195-
match existing {
196-
Some(t) => t,
197-
None => {
198-
println!("{} No source found matching '{}'", "✗".red(), id);
199-
return Ok(());
200-
}
201-
};
194+
let (full_id, current_name, current_url, current_username) = match existing {
195+
Some(t) => t,
196+
None => {
197+
println!("{} No source found matching '{}'", "✗".red(), id);
198+
return Ok(());
199+
}
200+
};
201+
202+
if let Some(url) = url.as_deref() {
203+
crate::caldav::validate_caldav_url(url)?;
204+
}
202205

203206
let url_or_username_changed = url.is_some() || username.is_some();
204207
let new_name = name.unwrap_or(current_name);
@@ -222,7 +225,6 @@ pub async fn run(pool: &SqlitePool, key: &[u8; 32], cmd: SourceCommands) -> Resu
222225
.execute(pool)
223226
.await?;
224227
} else {
225-
let _ = current_password_enc;
226228
sqlx::query(
227229
"UPDATE caldav_sources SET name = ?, url = ?, username = ? WHERE id = ?",
228230
)

0 commit comments

Comments
 (0)