Skip to content

Preserve Unicode URL characters and clean typographic quotes - #5425

Open
satiricalguru wants to merge 3 commits into
aboutcode-org:developfrom
satiricalguru:fix/issue-4475-unicode-url-extraction
Open

satiricalguru wants to merge 3 commits into
aboutcode-org:developfrom
satiricalguru:fix/issue-4475-unicode-url-extraction

Conversation

@satiricalguru

@satiricalguru satiricalguru commented Nov 6, 2026 •

Copy link
Copy Markdown

Fixes #4475

ScanCode truncates or transliterates URL paths such as the Slovak and Cyrillic Wikipedia links in the issue. Preserve Unicode characters through URL normalization so the output points to the original path.

Normalize typographic quotes, remove invisible formatting marks, and trim trailing Unicode punctuation. If CJK prose joins two bare HTTP links into one candidate, recover the pair when the second scheme and sentence punctuation identify it. Update the stored URLs used for license clue filtering.

Validation

  • Finder and clue-filter tests on Python 3.12: 69 passed and 2 existing expected failures. The two regressions for prose and punctuation fail against the previous finder implementation.

  • Full license ignorable-clue validation: 37,669 passed. The two failures are the same FSL assertions reported on upstream develop.

  • GitHub reported 31 passing checks. The failed Azure job reproduced the same two FSL assertions as upstream, which also caused its parent pipeline to fail.

Tasks

  • Reviewed the contribution guidelines.
  • Linked the original issue.
  • Upstream CI completed for the revised commit. See the results above.
  • Updated CHANGELOG.rst and AUTHORS.rst.

AI assistance: Codex assisted with investigation, implementation and local tests.

Fixes aboutcode-org#4475

AI-assisted: Codex assisted with investigation, implementation and local tests.
Signed-off-by: Jatin Pandey <jatinjio1212@gmail.com>
Limit Unicode preservation to URL matches. Retain the existing punctuation cleanup and discard invisible formatting marks. Update four stored ignorable URL values to match extraction without changing the license texts.

Signed-off-by: Jatin Pandey <jatinjio1212@gmail.com>
@knowprasad

Copy link
Copy Markdown

Took a look through the changes in cluecode/finder.py and the updated rule data.

Supporting Unicode in URLs for issue #4475 (like the Cyrillic and Slovak Wikipedia paths) is a great improvement. However, setting ascii_matches=False reveals a couple of edge cases in how URL boundaries and trailing punctuation are handled:

  1. In src/cluecode/finder.py, url_body is defined as [^\s<>\[\]"]. With Unicode matching enabled, non-whitespace characters in languages without word spaces get matched directly into the URL. We can see this in cc-by-sa-2.1-jp.LICENSE, where the Japanese sentence (から、クリエイティブ...) immediately following https://creativecommons.org/ was absorbed into the URL.
  2. In end_of_url_cleaner(), trailing characters are stripped using string.punctuation, which only covers ASCII symbols. Unicode punctuation like ¬ (\u00ac), † (\u2020), or CJK full stops 。 (\u3002) remain attached to the URL and end up percent-encoded, which is why http://www.mozilla.org/MPL/.%C2%AC%E2%80%A0 appeared in mpl-1.1_or_gpl-2.0-plus_3.RULE.

Having to add percent-encoded sentence fragments and punctuation to .LICENSE and .RULE files usually indicates the extractor over-matched trailing characters. If we update end_of_url_cleaner() to clean Unicode punctuation (for example checking unicodedata.category(char).startswith('P') or explicit CJK punctuation), URLs like http://www.mozilla.org/MPL/ will trim cleanly without needing changes to existing license rules.

Trim raw trailing Unicode punctuation and recover paired bare HTTP origins separated by CJK prose. Keep ordinary Unicode paths and align the stored URLs used by license clue filtering.

Signed-off-by: Jatin Pandey <jatinjio1212@gmail.com>

This branch has not been deployed

No deployments
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.

Incorrect/incomplete extraction of URLs with special characters

2 participants