Skip to content

Commit c8a5fa1

Browse files
fixup: use validated str from validate_resource_name; also validate range
- drive: use the &str returned by validate_resource_name(parent)? directly in json! rather than the original untrusted input - sheets: validate config.range in both build_append_request and build_read_request, since the range is used as a URL path segment in the Sheets API (spreadsheets/{id}/values/{range})
1 parent b03428d commit c8a5fa1

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

crates/google-workspace-cli/src/helpers/drive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn build_metadata(filename: &str, parent_id: Option<&str>) -> Result<Value, GwsE
148148
});
149149

150150
if let Some(parent) = parent_id {
151-
crate::validate::validate_resource_name(parent)?;
151+
let parent = crate::validate::validate_resource_name(parent)?;
152152
metadata["parents"] = json!([parent]);
153153
}
154154

crates/google-workspace-cli/src/helpers/sheets.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ fn build_append_request(
210210
doc: &crate::discovery::RestDescription,
211211
) -> Result<(String, String, Vec<String>), GwsError> {
212212
crate::validate::validate_resource_name(&config.spreadsheet_id)?;
213+
crate::validate::validate_resource_name(&config.range)?;
213214

214215
let spreadsheets_res = doc
215216
.resources
@@ -243,6 +244,7 @@ fn build_read_request(
243244
doc: &crate::discovery::RestDescription,
244245
) -> Result<(String, Vec<String>), GwsError> {
245246
crate::validate::validate_resource_name(&config.spreadsheet_id)?;
247+
crate::validate::validate_resource_name(&config.range)?;
246248

247249
// ... resource lookup omitted for brevity ...
248250
let spreadsheets_res = doc

0 commit comments

Comments
 (0)