Skip to content

fix: Ignore emoji shorthand codes in URIs #1847

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

Merged
merged 4 commits into from
Aug 3, 2022
Merged

Conversation

socsieng
Copy link
Contributor

@socsieng socsieng commented Jul 30, 2022

Fixes: #1823,
Fixes: #1839

Summary

Fixes an issue related to unintentional processing of emoji shorthand codes when included in a URI

What kind of change does this PR introduce?

Bugfix

For any code change,

  • Related documentation has been updated if needed
  • Related tests have been updated or tests have been added

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

Related issue, if any:

Tested in the following browsers:

Using: https://codesandbox.io/s/thirsty-fog-inwfl8

  • Chrome
  • Firefox
  • Safari
  • Edge
  • IE

@vercel
Copy link

vercel bot commented Jul 30, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
docsify-preview ✅ Ready (Inspect) Visit Preview Sep 2, 2022 at 10:53PM (UTC)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 30, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 62069de:

Sandbox Source
docsify-template Configuration
clever-pond-ide4hb PR
crazy-cdn-m0skqy Issue #1823
nice-mclaren-lbeew1 Issue #1823

Copy link
Member

@jhildenbiddle jhildenbiddle left a comment

Choose a reason for hiding this comment

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

Thanks for submitting the PR, @socsieng.

There is a much easier fix: simply add a to the existing list of tags that are being marked:

// Mark colons in tags
.replace(
/<(code|pre|script|template)[^>]*?>[\s\S]+?<\/(code|pre|script|template)>/g,
m => m.replace(/:/g, '__colon__')
)

Change this line:

/<(code|pre|script|template)[^>]*?>[\s\S]+?<\/(code|pre|script|template)>/g,

To this:

/<(a|code|pre|script|template)[^>]*?>[\s\S]+?<\/(a|code|pre|script|template)>/g,

This fix also addresses an issue with the regex you were using in your initial PR.

@socsieng
Copy link
Contributor Author

socsieng commented Jul 30, 2022

Wouldn't marking the a tags be too broad? I can imagine emojis being used in the content of a tags today.

Examples:

- Without explicit scheme (i.e. starting with `//`)
- In single and double quote strings
- Within unquoted HTML tag attributes
- In css `url()` values
Copy link
Member

@jhildenbiddle jhildenbiddle left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks again, @socsieng.

@jhildenbiddle jhildenbiddle requested review from a team August 3, 2022 01:43
Copy link
Member

@sy-records sy-records left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!

@sy-records sy-records merged commit 3c9b3d9 into docsifyjs:develop Aug 3, 2022
@socsieng
Copy link
Contributor Author

socsieng commented Aug 3, 2022

Any ideas about when these changes will be available in npm?

@sy-records
Copy link
Member

Not sure when npm will be released.

But you can try https://github.com/sy-records/docsify-nightly

@trusktr
Copy link
Member

trusktr commented Aug 3, 2022

You can also try installing from github using npm. To install from develop:

npm install "docsify@docsifyjs/docsify#develop"

Or to install from a commit:

npm install "docsify@docsifyjs/docsify#3c9b3d9702bb05a5ff45a4ce4233e144cf1ebecb"

Or any git ref:

npm install "docsify@docsifyjs/docsify#<GIT_REF_GOES_HERE>"

which can be a tag, branch, etc.

@socsieng
Copy link
Contributor Author

socsieng commented Aug 3, 2022

Thanks. Appreciate the help.

I was more wondering what the timelines were to determine if I should wait for a formal package update or if I should use a github based version.

@jhildenbiddle
Copy link
Member

@socsieng --

I think we're close to pushing an update. There's one other PR that I'd like to see merged before we do so, but otherwise I don't think anyone would have an issue pushing a new minor or patch release (have to check history to determine which would be appropriate). I'll see if I can wrap that up today or tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants