Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for backslash escape in wikilinks #471

Merged
merged 3 commits into from
Sep 28, 2024

Conversation

digitalmoksha
Copy link
Collaborator

Adds support for using markdown backslash escapes in wikilink titles. So you can now use [ and ] in the title. For example [[Name \[of\] page]] or [[Name \[of\] page|https://example.org]]

Closes #470

Copy link
Contributor

Command Mean [ms] Min [ms] Max [ms] Relative
./bench.sh ./comrak-33e2703 320.8 ± 1.0 319.4 323.2 2.89 ± 0.10
./bench.sh ./comrak-main 321.2 ± 1.9 319.1 327.7 2.90 ± 0.10
./bench.sh ./pulldown-cmark 110.9 ± 3.9 109.5 130.5 1.00
./bench.sh ./cmark-gfm 115.1 ± 1.3 112.9 119.7 1.04 ± 0.04
./bench.sh ./markdown-it 482.9 ± 3.7 476.1 490.2 4.35 ± 0.16

Run on Wed Sep 25 23:28:09 UTC 2024

@digitalmoksha
Copy link
Collaborator Author

digitalmoksha commented Sep 26, 2024

Ran fuzzing and got a failure

cargo fuzz tmin all_options fuzz/artifacts/all_options/crash-05d3afe47da506bec3093ecbee89e067b36b6a4e

Reproduction input

[\0\0\0\0\0][[\u{2} \\y \\\X/\L2\ \\X\ ]]\ \\[][Es0<fRaM[Se\n-:\X/\\2\

I'll try and track it down tomorrow.

Copy link
Owner

@kivikakk kivikakk left a comment

Choose a reason for hiding this comment

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

LGTM with one minor change (see comment), and escapes already roundtrip correctly in the CommonMark formatter!

}
}

container.append(self.make_inline(
Copy link
Owner

Choose a reason for hiding this comment

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

Let's check if startpos != offset here, otherwise we'll append an empty span when a wikilink title ends in an escaped character.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great point, thank you @kivikakk. Done.

@digitalmoksha
Copy link
Collaborator Author

After fixing the string overrun, I ran fuzzing for about 18 hours, no problems

@kivikakk
Copy link
Owner

Yes, LGTM!

@digitalmoksha digitalmoksha merged commit 5066a0e into main Sep 28, 2024
39 checks passed
@digitalmoksha digitalmoksha deleted the bw-wikilink-title-escape branch September 28, 2024 15:51
@digitalmoksha digitalmoksha changed the title Add support fo backslash escape in wikilinks Add support for backslash escape in wikilinks Sep 28, 2024
@digitalmoksha
Copy link
Collaborator Author

@kivikakk wdyt, could we cut a release for this?

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.

Wikilink titles can't handle escaped characters
2 participants