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: Fix pug-lexer parsed escaped interpolations incorrectly #3299

Conversation

shirohana
Copy link
Contributor

Pug-lexer always parsed escaped interpolations (\#{...} and \!{...}) into #{...}.

Here's the sample: https://runkit.com/shirohana/5f99255fb3cdb4001a711cf9

const { Lexer } = require('pug-lexer')

const code = `
p \\#{value}
p \\!{value}
`
const lexer = new Lexer(code, { filename: 'index.pug' })
const tokens = lexer.getTokens()
// Passed
assert(
  tokens[2].val === '#{value}',
  `1. expect "#{value}", actual: "${tokens[2].val}"`
)

// Throws
assert(
  tokens[5].val === '!{value}',
  `2. expect "!{value}", actual: "${tokens[5].val}"`
)

@rollingversions
Copy link

rollingversions bot commented Oct 28, 2020

pug-lexer (5.0.0 → 5.0.1)

Bug Fixes

  • Handle escaped unsafe interpolation correctly

    If you want to put the literal text #{ in your html, it needs to be escaped to indicate that it should not be treated as interpolation. The same is true of !{ You can escape them by prefixing them with \, e.g.

    p These are some \#{ weird \!{ symbols

    Previously this would have incorrectly converted both escaped sequences to #{, resulting in the html:

    <p>These are some #{ weird #{ symbols</p>

    Now this correctly generates:

    <p>These are some #{ weird !{ symbols</p>

Packages With No Changes

The following packages have no user facing changes, so won't be released:

  • pug
  • pug-attrs
  • pug-code-gen
  • pug-error
  • pug-filters
  • pug-linker
  • pug-load
  • pug-parser
  • pug-runtime
  • pug-strip-comments
  • pug-walk

Edit changelogs

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