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

Wrong HTML escape sequences in demo #63

Closed
Enter-tainer opened this issue Aug 11, 2020 · 7 comments · Fixed by #66
Closed

Wrong HTML escape sequences in demo #63

Enter-tainer opened this issue Aug 11, 2020 · 7 comments · Fixed by #66

Comments

@Enter-tainer
Copy link
Contributor

Enter-tainer commented Aug 11, 2020

image

It seems that the implementation of html escape is wrong.

function escapeHtml(html: string) {
  return html
    .replace(/&/g, '&')
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;')
    .replace(/&/g, '&amp;')
    .replace(/'/g, '&apos;')
}

It firstly converts > to &gt, then converts &gt to &ampgt, which is not what we expected.

I suggest checking out the implementation of lodash.

@Enter-tainer Enter-tainer changed the title Wrong escape sequences in demo Wrong HTML escape sequences in demo Aug 11, 2020
@Enter-tainer
Copy link
Contributor Author

This bug might be introduced from #59.

@Enter-tainer
Copy link
Contributor Author

See lodash/escape. Instead of escaping these charactors in several passes(which is buggy), we should escape all these charactors at the same time.

antfu added a commit to antfu/shiki that referenced this issue Aug 16, 2020
closes shikijs#63, and makes the process done in one pass. Thanks to @Enter-tainer 's suggestions.
@antfu antfu mentioned this issue Aug 16, 2020
@orta orta closed this as completed in #66 Aug 16, 2020
@yzhang-gh
Copy link
Contributor

Do we only escape HTML code snippets? I am using the vuepress plugin and found <> not escaped, for example

conda create -n <env_name>

without specifying any language id, produces a result (visually) like this

conda create -n 

@octref
Copy link
Collaborator

octref commented Sep 16, 2020

We escape HTML output.

@yzhang-gh
Copy link
Contributor

@octref
Copy link
Collaborator

octref commented Sep 17, 2020

Please provide a reproducible case with reproducing steps.

@yzhang-gh
Copy link
Contributor

Here you go (#93).

octref added a commit that referenced this issue Sep 22, 2020
antfu added a commit that referenced this issue Jan 26, 2024
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 a pull request may close this issue.

3 participants