Skip to content

[rejected AI] Fix urlencode treating UserDict keys as query pairs - #2276

Closed
jaideeppyne wants to merge 1 commit into
pallets:mainfrom
jaideeppyne:fix-urlencode-mapping
Closed

jaideeppyne wants to merge 1 commit into
pallets:mainfrom
jaideeppyne:fix-urlencode-mapping

Conversation

@jaideeppyne

@jaideeppyne jaideeppyne commented Sep 16, 2026 •

Copy link
Copy Markdown

urlencode only called .items() for dict, so mapping types such as UserDict and MappingProxyType were iterated as keys. String keys then unpacked into (character, character) pairs and produced a corrupted query string.

from collections import UserDict
from jinja2 import Environment

Environment().from_string("{{ q|urlencode }}").render(q=UserDict({"Aa": "PersonA@123.com"}))
# before: A=a
# after:  Aa=PersonA%40123.com

Fixes #2269

urlencode only called .items() for dict, so Mapping types such as
UserDict and MappingProxyType were iterated as keys. String keys
then unpacked into (character, character) pairs and produced a
corrupted query string.

Fixes pallets#2269
@jaideeppyne jaideeppyne changed the title fix: do not pad slice filter when length divides evenly Fix urlencode treating UserDict keys as query pairs Sep 16, 2026
@davidism

Copy link
Copy Markdown
Member

@davidism davidism closed this Sep 16, 2026
@davidism davidism changed the title Fix urlencode treating UserDict keys as query pairs [rejected AI] Fix urlencode treating UserDict keys as query pairs Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Something wrong occurred when generating a string for UserDict

2 participants