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: Replace use of startsWith and endsWith with regex for IE11 #1877

Merged
merged 1 commit into from
Dec 15, 2020

Conversation

jhildenbiddle
Copy link
Contributor

Marked version: 1.2.6 (not sure when change was introduced)

Markdown flavor: n/a

Description

Expectation

No errors in IE11.

Specifically, marked 1.x is a dependency of https://docsify.js.org which still supports IE11. Goal is to restore IE11 functionality by fixing this issue within marked.

Result

After fixes, no erros in IE11.

What was attempted

Replaced use of String.startsWith() and String.endsWith() with regular expression tests.

Contributor

Verified all tests succeeded
Manually verified changes worked in IE11

  • Test(s) exist to ensure functionality and minimize regression (if no tests added, list tests covering this PR); or,
  • no tests required for this PR.
  • If submitting new feature, it has been documented in the appropriate places.

Committer

In most cases, this should be a different person than the contributor.

@vercel
Copy link

vercel bot commented Dec 14, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/markedjs/markedjs/k5aqw8zes
✅ Preview: https://markedjs-git-fix-1876.markedjs.now.sh

Copy link
Member

@UziTech UziTech left a comment

Choose a reason for hiding this comment

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

LGTM. FYI we are planning on releasing v2 soonish and we will be dropping es5 support at that time.

@calculuschild
Copy link
Contributor

@UziTech is there any concern with redos? Would string[0], string[string.length] be better?

@jhildenbiddle
Copy link
Contributor Author

jhildenbiddle commented Dec 15, 2020

@UziTech Sounds good.

Similarly, we're just tidying up loose ends on docsify v4 (which supports IE11) before moving on to v5 (which will also drop support for IE11). There's no expectation of long-term IE support from marked. We're all ready to put those dark days behind us. 😉

@UziTech
Copy link
Member

UziTech commented Dec 15, 2020

@calculuschild no there are no quantifiers so it can't be vulnerable but string.charAt(string.length - 1) is probably faster though.

@UziTech UziTech merged commit 4fdde20 into markedjs:master Dec 15, 2020
github-actions bot pushed a commit that referenced this pull request Dec 15, 2020
## [1.2.7](v1.2.6...v1.2.7) (2020-12-15)

### Bug Fixes

* Replace use of startsWith and endsWith with regex for IE11 ([#1877](#1877)) ([4fdde20](4fdde20)), closes [#1876](#1876)
@github-actions
Copy link

🎉 This PR is included in version 1.2.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

Use of startsWith and endsWith breaks IE11
4 participants