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

Fix #1321. Link references escaping HTML. #1322

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

MABruni
Copy link
Contributor

@MABruni MABruni commented Jan 12, 2024

This is a fix for #1321.

EncodeURI was targeting the entire URL. This PR makes the following changes:

  • Only filenames are targeted by encodeURI now. This preserves especial characters in the base path. Notes with names that contain especial characters are encoded and link correctly inside VSCode.
  • Blank spaces are not encoded now. Notes that contain them are back to using angel brackets.

Feedback would be greatly appreciated. Thank you!

@riccardoferretti
Copy link
Collaborator

Thanks for the PR, a couple of questions:

Only filenames are targeted by encodeURI now

What if an element of the path has special characters? Is that addressed by the <> syntax? Can you add a test for that?

Blank spaces are not encoded now

What happens if the filename has spaces in it?

Looking back at the problem that #1298 was solving, I wonder if escaping would work as well as encoding. Wdyt?

@MABruni
Copy link
Contributor Author

MABruni commented Jan 15, 2024

The base path should be folder names, so I did not cover that case (for example, windows doesn't allow using special characters in folders). But, I could change the logic to encode everything except the forward slashes, that should take care of special characters everywhere and preserve link functionality across HTML and markdown.

If the filename has spaces in it the behavior is the same as before #1311. The wikilink url is enclosed in angle brackets and links correctly. For example, if a link is created to a page titled 'another page' it will appear like <docs/features/another page>. Honestly, I prefer having consistency and using percent encoding for everything, but I agree that using angle brackets makes it more readable. Both options work, so I'd be happy to go with your preferred one.

With regard to #1298, percent encoding is considered escaping special characters while preserving link functionality, and it is my understanding that percent encoding gives broader compatibility (works on HTML and markdown) and is the standard for urls. That is why I decided on that approach.

@riccardoferretti riccardoferretti merged commit 2fba6e9 into foambubble:master Jan 15, 2024
3 checks passed
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.

None yet

2 participants