Skip to content

Permissive autolinks: relaxing syntax to accept more real world cases. - #454

Merged
mity merged 4 commits into
masterfrom
autolinks
Oct 13, 2026
Merged

mity merged 4 commits into
masterfrom
autolinks

Conversation

@mity

@mity mity commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

There was a conflict between PR #449 and #452.

The first added support specifically for port numbers and allowed one-component hostnames. The other one generalizes/relaxes the syntax in a more substantive way but was not as strict vis-a-vis the port numbers.

This is a merge of both (or strictly speaking #452 rebased on top of master witch now includes #449; plus removal/fix of invalidated test cases). I'll ask authors of both PRs for kind review/testing in your environment and approval of this.

cc @hryhoriiK97 @emschorsch

(Also note even after merging this I'll keep this in my mind with a little question mark, as the permissive autolinks are always a dance between false positives and false negatives and only some time will show whether some false positives are reported; certainly do not expect some official release with this in a short time period.)

@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.06%. Comparing base (58c55b6) to head (1dac5bc).

Files with missing lines Patch % Lines
src/md4c.c 90.90% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #454      +/-   ##
==========================================
+ Coverage   78.93%   79.06%   +0.12%     
==========================================
  Files           5        5              
  Lines        3865     3883      +18     
  Branches     1294     1300       +6     
==========================================
+ Hits         3051     3070      +19     
+ Misses        297      296       -1     
  Partials      517      517              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@emschorsch

Copy link
Copy Markdown
Contributor

Looks good, thanks you!

@hryhoriiK97 hryhoriiK97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested this branch against all the cases from #449 and everything still works, full test suite passes here too.

One thing I noticed, and it's actually a leftover from #449, not from this PR: the host scanner's rollback step runs even when it consumed nothing, so an empty host after http:// counts as one component. Master already links http://?q=1 and http://.com; with the new tail scan it also links http:///path, http://:3000 and http://[.

A one-line guard on the rollback (&& off != scan_beg) fixes it and keeps the suite green, without touching any of the tail logic here. Happy to send it as a small follow-up PR once this is merged, or you can fold it in, whichever you prefer.

Otherwise looks good to me.

@mity

mity commented Oct 13, 2026

Copy link
Copy Markdown
Owner Author

@hryhoriiK97 Good catch.

Thx to both of you.

mity and others added 4 commits October 13, 2026 16:04
The segmented path/query/fragment allowlists reject or truncate ordinary
URLs containing colons, repeated semicolons, redirect URLs and percent
escapes. A numeric port after a host is also rejected, and unmatched
opening parentheses prevent the canonical GFM www example from linking.

Scan the tail continuously with md4c's Unicode decoding and resolved-mark
checks, then trim terminal punctuation and excess closing parentheses.
Reuse ISUNICODEWHITESPACE_ so the ASCII-only build remains supported.
Keep the existing host, preceding-boundary and e-mail rules. No dependency
or public API is added. Host-colon tails remain permissive rather than
validating numeric ports; document this policy and its overlap with #449.

Extend the existing permissive-autolink specification with 12 examples
covering paths, queries, fragments, parentheses, Unicode, terminal
punctuation and Markdown boundaries. Nine examples fail before the fix.
The full Debug/Release suites and focused sanitizer tests pass locally.

Downstream report: https://bugs.documentfoundation.org/show_bug.cgi?id=169429
Downstream patch: https://gerrit.libreoffice.org/c/core/+/212109
Related proposal: #449

Signed-off-by: Emanuel Schorsch <[email protected]>
Assisted by GPT 6.1 Sol High
@mity
mity merged commit 1645761 into master Oct 13, 2026
21 checks passed
mity pushed a commit that referenced this pull request Oct 19, 2026
Since the URL tail runs until whitespace (#454) and only excess ')' is
trimmed at its end, a URL enclosed in square brackets or braces swallows
the closing one: "[http://example.com/x]" links "http://example.com/x]",
where 0.6.0 kept the ']' outside the link.

Apply the same rule to ']' and '}' as to ')': only excess closing ones at
the end of the tail are excluded, so "https://example.org/a[b]c" is still
linked whole.
mity added a commit that referenced this pull request Oct 19, 2026
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.

3 participants