Skip to content

Don't use endsWith, produce cleaner output, fix text with a lone quote - #41

Merged
developit merged 3 commits into
developit:custom-jsx-parserfrom
jviide:custom-jsx-parser-03
Dec 18, 2018
Merged

developit merged 3 commits into
developit:custom-jsx-parserfrom
jviide:custom-jsx-parser-03

Conversation

@jviide

@jviide jviide commented Dec 17, 2018 •

Copy link
Copy Markdown
Collaborator

This pull request implements the following fixes and modifications:

  • Get rid of the .endsWith usage, making the library more compatible. Generated functions now avoid empty objects, so <a ...${{ foo: 'bar' }} /> produces h('a', Object.assign({}, $_h[1])) instead of h('a', Object.assign({}, $_h[1], {})). This is done by keeping track of the characters needed to close the current props section and the possible current spread. The tracked characters also double as flags, empty string being false.
  • Fix cases where atext part contains a lone single or double quote, such as <a>foo "<b /></a>. Add a related test.
  • The whitespace normalization pattern replace(/^\s*\n+\s*|\s*\n+\s*$/g,'') was susceptible to ReDoS. Alleviated this by changing \n+ to \n.

@jviide
jviide changed the base branch from master to custom-jsx-parser December 17, 2018 22:47
@jviide jviide changed the title Don't use endsWith & produce cleaner output Don't use endsWith, produce cleaner output, fix text with a lone quote Dec 18, 2018
Comment thread src/index.mjs Resolved
@developit
developit merged commit b4ac1bc into developit:custom-jsx-parser Dec 18, 2018
@jviide
jviide deleted the custom-jsx-parser-03 branch December 18, 2018 01:55
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.

2 participants