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

Invalid character substitution of string with \x85 (\u0085) #1313

Closed
erny opened this issue Nov 20, 2020 · 2 comments · Fixed by #1366
Closed

Invalid character substitution of string with \x85 (\u0085) #1313

erny opened this issue Nov 20, 2020 · 2 comments · Fixed by #1366
Milestone

Comments

@erny
Copy link

erny commented Nov 20, 2020

When expanding a template with strings that contain \x85, a new line character is inserted. En case of JavaScript, this results in errores.

How to reproduce:

>>> import jinja2
>>> jinja2.Template('Hello\x85World').render()
'hello\nWorld'

Expected:

'hello\x85World'

Environment:

  • Python version: 3.8.5
  • Jinja version: 2.11.2
@erny
Copy link
Author

erny commented Nov 20, 2020

It seems that the the minified JS includes a polyfill for String.trim, String.trimStart, String.trimEnd which includes the string: \u200b\u0085\u180e (./internals/string-trim-forced.js), so:

  >>> jinja2.Template('\u200b\u0085\u180e').render()
  '\u200b\n\u180e'

This will produce invalid JS.

@davidism
Copy link
Member

Duplicate of #769

@davidism davidism marked this as a duplicate of #769 Nov 20, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2020
@davidism davidism added this to the 3.0.0 milestone Mar 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants