Skip to content

Quote Drive query literals; confine ids to Drive's id alphabet - #10

Merged
thorwhalen merged 3 commits into
masterfrom
escape-drive-queries
Sep 22, 2026
Merged

thorwhalen merged 3 commits into
masterfrom
escape-drive-queries

Conversation

@thorwhalen

@thorwhalen thorwhalen commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Closes #9

  • _q() quotes values as Drive query-language literals (backslash and single quote escaped); used for every name/id placed in a q query.
  • File/folder ids parsed from URLs are limited to [A-Za-z0-9_-]+ (they double as local cache file names).

Independent refute-review done; fixed from it: bare ids are fully anchored (trailing newline), the uc? pattern takes the id= parameter itself (not e.g. x_id=), upload() test, README example. Open question it raised: Drive v2 backslash-escaping is documented for v3; if v2 differs, a title containing a backslash would not match an existing file (duplicate instead of update) — not a security issue.

Normal names/ids behave as before. No fleet dependents.

Tests: tests/test_query_escaping.py (fake Drive capturing the queries); fail on master.

🤖 Generated with Claude Code

thorwhalen and others added 3 commits September 22, 2026 15:17
File and folder names were spliced into Drive search queries between
single quotes, so a key like "x' or title contains '" rewrote the query.
Names and ids are now escaped as query literals, and ids parsed from URLs
are limited to [A-Za-z0-9_-] (they are also used as local cache paths).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- Bare ids use fullmatch (a trailing newline no longer passes).
- The uc? URL pattern takes the id= parameter itself, not the last
  parameter name ending in id=.
- Test for upload()'s query; README example no longer suggests splicing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@thorwhalen
thorwhalen merged commit 14764ec into master Sep 22, 2026
12 checks passed
@thorwhalen
thorwhalen deleted the escape-drive-queries branch September 22, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quote names in Drive queries; validate parsed ids

1 participant