Skip to content

printer: fix hyperlink paths that are not valid UTF-8 - #3550

Open
dualfroz wants to merge 1 commit into
BurntSushi:masterfrom
dualfroz:fix/3526-hyperlink-non-utf8
Open

dualfroz wants to merge 1 commit into
BurntSushi:masterfrom
dualfroz:fix/3526-hyperlink-non-utf8

Conversation

@dualfroz

Copy link
Copy Markdown

on unix a path can contain bytes that aren't valid UTF-8. HyperlinkPath::encode copied every byte >= 128 as is, so the URI wasn't valid and raw bytes ended up inside the OSC 8 sequence.

bytes that aren't part of valid UTF-8 are now percent-encoded (the loop goes over utf8_chunks()). valid non-ascii is still left unencoded like before, since encoding it breaks file:// URLs on windows (as the doc comment on encode says). nothing changes on windows, the path is always valid UTF-8 there.

added encode_invalid_utf8 and a CHANGELOG entry. grep-printer tests pass.

Fixes #3526

On Unix, a path may contain bytes that are not valid UTF-8. These were
copied verbatim into the hyperlink URI, which makes for an invalid URI
and puts raw bytes outside 32-126 into the OSC 8 escape sequence.

Non-ASCII characters in valid UTF-8 are still left unencoded, as before,
since encoding them breaks file:// URLs on Windows. Bytes that are not
part of valid UTF-8 are now percent-encoded.

Fixes BurntSushi#3526
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.

Hyperlink URI contains raw non-UTF-8 path bytes on Unix

1 participant