Skip to content

Commit

Permalink
Bug fix for javascript rendering (#6362) (#6363)
Browse files Browse the repository at this point in the history
* Check template name when rendering also

* Update i18n.py

Enforce stringiness

(cherry picked from commit b42f3de)

Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
  • Loading branch information
github-actions[bot] and SchrodingersGat committed Jan 30, 2024
1 parent c12e6db commit 9494a8a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion InvenTree/part/templatetags/i18n.py
Expand Up @@ -52,7 +52,18 @@ def render(self, context):
# Escape any quotes contained in the string, if the request is for a javascript file
request = context.get('request', None)

if self.escape or (request and request.path.endswith('.js')):
template = getattr(context, 'template_name', None)
request = context.get('request', None)

escape = self.escape

if template and str(template).endswith('.js'):
escape = True

if request and str(request.path).endswith('.js'):
escape = True

if escape:
result = result.replace("'", r'\'')
result = result.replace('"', r'\"')

Expand Down

0 comments on commit 9494a8a

Please sign in to comment.