Skip to content

Report malformed percent-escapes in Google resource URLs - #272

Closed
snowyukitty wants to merge 1 commit into
cloudflare:mainfrom
snowyukitty:fix/google-url-decode-errors
Closed

Report malformed percent-escapes in Google resource URLs#272
snowyukitty wants to merge 1 commit into
cloudflare:mainfrom
snowyukitty:fix/google-url-decode-errors

Conversation

@snowyukitty

@snowyukitty snowyukitty commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

What does this change?

Binding a Google resource from a URL containing a bare % throws an unhandled URIError: URI malformed instead of the explanatory errors every sibling validation path in getGatekeeperClassFor() raises. https://mail.google.com/mail/u/0/#search/50%off is the reproduction reported in #55.

This adds a decodeResourceUrlPart() helper — decodeURIComponent() in a try, rethrowing as Invalid <part>: it cannot be percent-decoded. Encode a literal "%" as "%25". — and uses it at the four bare decode sites in getGatekeeperClassFor(): the Gmail #search/ query, the Gmail #label/ name, the Google Calendar path segment, and the BigQuery path segments.

#55 notes the same bare-decode pattern in other gatekeeper packages; this PR deliberately stays on the reported backend path to remain a small, single-concern change.

Fixes #55

Why is this obviously correct and trivially verifiable?

The success path returns exactly what decodeURIComponent() returned, unchanged. The only behavioral difference is that a thrown URIError becomes an Error whose message follows the wording style of the sibling validation messages in the same function. There are no control-flow, dependency, or API changes.

Verified on Windows 11 (Node 22.22.3, pnpm 11.17.0) against 4288713: tsc -p packages/gatekeeper-google and full pnpm lint pass.

AI tools authored this patch under human direction, and an independent AI review approved it before submission; the verification commands above were run locally.

Checklist

Checking every item does not guarantee acceptance. Maintainers determine whether
a pull request meets the contribution policy.

  • This is a small, concrete change; it is not a feature, refactor, or low-value cleanup.
  • I understand that maintainers decide whether the change is obviously correct and trivially verifiable.
  • I have read and followed the contribution guidelines.

🤖 Generated with Claude Code


Open in Devin Review

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the gatekeeper Changes to a gatekeeper integration label Aug 19, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@snowyukitty

Copy link
Copy Markdown
Contributor Author

Closing this myself: CONTRIBUTING asks contributors to keep PRs to "a dozen or so lines" and this one is +16/-4, which is over that line. #221 was the right size and I should have kept to it here.

Leaving the report behind in case it is useful: in packages/gatekeeper-google/src/google.ts, decodeURIComponent is called on parts of a Google resource URL, so an unescaped literal % — a Gmail search or label like "50% off" — throws a bare URIError that does not say which part of the URL failed to decode.

I am not reopening this as a smaller PR. Splitting a change to fit the size guideline would be evading it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gatekeeper Changes to a gatekeeper integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gmail URLs containing a bare % throw an unhandled URIError when binding a resource

1 participant