Skip to content

fix: correct URL double-escaping in sitemap generation#45

Merged
ruibaby merged 2 commits intohalo-dev:mainfrom
ruibaby:fix/url-double-escaping
Apr 27, 2026
Merged

fix: correct URL double-escaping in sitemap generation#45
ruibaby merged 2 commits intohalo-dev:mainfrom
ruibaby:fix/url-double-escaping

Conversation

@ruibaby
Copy link
Copy Markdown
Member

@ruibaby ruibaby commented Apr 27, 2026

Summary

  • UrlUtils.toURI() was calling escapeSitemapUrl() internally, while SitemapGeneratorOptions.transform() already called it before passing the URL in
  • This caused & to be escaped twice: &&&, producing invalid URLs in the generated sitemap
  • Remove the redundant escapeSitemapUrl() call from toURI() so that callers are solely responsible for XML entity escaping
  • Update the test assertion to reflect the correct single-escaped output

Test plan

  • SitemapGeneratorOptionsTest.transform() — verify the absolute URL case now produces single-escaped output (< / > / & instead of < / > / &)
  • Verify generated sitemap XML parses correctly in browsers / validators

Made with Cursor

修复 sitemap 列表中带特殊字符的链接生成错误的问题

UrlUtils.toURI() was calling escapeSitemapUrl() internally, while
SitemapGeneratorOptions.transform() already called it before passing
the URL to toURI(). This caused & to be escaped twice: & -> & ->
&, producing invalid URLs in the generated sitemap.

Remove the redundant escapeSitemapUrl() call from toURI() so that
callers are solely responsible for escaping. Update the test assertion
to reflect the correct (single-escaped) output.

Made-with: Cursor
@f2c-ci-robot f2c-ci-robot Bot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Apr 27, 2026
@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented Apr 27, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ruibaby for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 27, 2026
Resolve conflict in SitemapGeneratorOptionsTest: keep the UrlEntryMeta
API introduced in upstream/main while applying the corrected expected
value from this branch (single-escaped <>& instead of the
double-escaped <>& produced by the bug).

Made-with: Cursor
@f2c-ci-robot f2c-ci-robot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Apr 27, 2026
@ruibaby ruibaby merged commit 00fe12c into halo-dev:main Apr 27, 2026
1 of 2 checks passed
@ruibaby ruibaby deleted the fix/url-double-escaping branch April 27, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant