fix(feedgenerator): percent-encode non-ASCII characters in get_tag_uri()#49
Open
balooii wants to merge 1 commit into
Open
fix(feedgenerator): percent-encode non-ASCII characters in get_tag_uri()#49balooii wants to merge 1 commit into
balooii wants to merge 1 commit into
Conversation
get_tag_uri() now percent-encodes non-ASCII characters in the URL path and fragment so the resulting tag URI is valid as per RFC 4151. The encoding is idempotent, so callers that already pass an encoded URL are unaffected This issue came up while validating the feed from gimp.org (uses pelican to create the feed) via W3C Feed Validation Service (https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fwww.gimp.org%2Ffeeds%2Fatom.xml). It complains that `id is not a valid TAG` for this item: ``` tag:www.gimp.org,2026-02-22:/news/2026/02/22/øyvind-kolås-interview-ww2017/ ``` which uses the non-ascii slug of that page. Interestingly feedgenerator itself does the url encoding before passing it to get_tag_uri but pelican doesn't do that and passes the raw IRI via writers. So I think it's best to ensure that get_tag_uri() returns a valid tag uri regardless of the input being already encoded or not.
|
@justinmayer @uda ping |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello 👋 ,
I noticed that Pelican created a feed that was marked as "does not validate" by W3C Feed Validation Service and traced it to feedgenerator not handing out url encoded uris via get_tag_uri() when non-ASCII characters are used in the path/fragment. This fixes it.
get_tag_uri() now percent-encodes non-ASCII characters in the URL path and fragment so the resulting tag URI is valid as per RFC 4151.
The encoding is
idempotent, so callers that already pass an encoded URL are unaffected
This issue came up while validating the feed from gimp.org (uses pelican to create the feed) via W3C Feed Validation Service (https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fwww.gimp.org%2Ffeeds%2Fatom.xml).
It complains that
id is not a valid TAGfor this item:which uses the non-ascii slug of that page.
Interestingly feedgenerator itself does the url encoding before passing it to get_tag_uri but pelican doesn't do that and passes the raw IRI via writers. So I think it's best to ensure that get_tag_uri() returns a valid tag uri regardless of the input being already encoded or not.