Skip to content

fix: strip trailing CJK/ASCII punctuation from bare URLs - #146

Merged
tiensonqin merged 3 commits into
masterfrom
logseq/fix-url-trailing-punct-7a85
Aug 30, 2026
Merged

fix: strip trailing CJK/ASCII punctuation from bare URLs#146
tiensonqin merged 3 commits into
masterfrom
logseq/fix-url-trailing-punct-7a85

Conversation

@tiensonqin

@tiensonqin tiensonqin commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Bare autolinks were incorrectly including trailing punctuation:

  • Chinese / (and related CJK punct) after a URL were absorbed into the link (also reported in Chinese period is parsed into URL logseq#7634)
  • English , / . after host-only URLs like http://example.com. were included (path URLs already stripped these)

Root cause: ending punctuation was only handled as ASCII chars in excluded_ending_chars. Multi-byte UTF-8 CJK punctuation could never match, and the host (before_path) parser did not apply trailing-ASCII rules at all.

Fix

  • Treat CJK punctuation (,。;!?、:) as hard URL terminators (never part of the URL)
  • Apply ASCII trailing punctuation stripping to the host part as well as the path
  • Extend string_contains_balanced_brackets with excluded_ending_strings for multi-byte stoppers

CI

  • Enable dune-cache: true on ocaml/setup-ocaml in Build and Format workflows (opam switch cache was already automatic)

Test plan

  • Added cases for host/path + English , . and Chinese
  • dune runtest passes
  • ocamlformat clean
Open in Web Open in Cursor 

Bare autolinks were swallowing trailing Chinese commas/periods (and
English punctuation after host-only URLs) because excluded ending
chars only covered ASCII bytes. Stop at multi-byte CJK punctuation
and apply the same trailing ASCII rules to the host part.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@tiensonqin
tiensonqin marked this pull request as ready for review August 30, 2026 00:56
Copilot AI lite review requested due to automatic review settings August 30, 2026 00:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

cursoragent and others added 2 commits August 30, 2026 01:01
Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
ocaml/setup-ocaml already caches the opam switch; turning on
dune-cache speeds up incremental dune builds across CI runs.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
@tiensonqin
tiensonqin merged commit 02d6fa1 into master Aug 30, 2026
4 of 5 checks passed
@tiensonqin
tiensonqin deleted the logseq/fix-url-trailing-punct-7a85 branch August 30, 2026 01:10
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.

4 participants