question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Encoding as HTML Entities to avoid code injection

See original GitHub issue

If the output is for a browser, then it can be a security issue (code injection, etc.) if the values are simply dumped straight into the output - rather, they should be encoded as HTML entities. To that end, it’s annoying doing it oneself before passing data to the templating engine. Is it planned to add support for this directly to pupa?

e.g. Maybe single braces {} means do it normally, and double braces ({{}}) could mean “escape it too please”? Or even the other way around.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
sindresorhuscommented, Oct 17, 2018

I never considered that type of usage, but sure. Double-braces would be a good syntax for that.

0reactions
sbrlcommented, May 1, 2019

Awesome, thanks 🎆

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cross Site Scripting Prevention - OWASP Cheat Sheet Series
Output Encoding is recommended when you need to safely display data exactly as a user typed it in. Variables should not be interpreted...
Read more >
Is htmlencoding a suitable solution to avoiding SQL injection ...
You should prevent sql injection by using parameter bindings (eg. never concatenate your sql strings with user input, but use place holders ...
Read more >
C4: Encode and Escape Data
Encoding and escaping are defensive techniques meant to stop injection attacks. Encoding (commonly called “Output Encoding”) involves translating special ...
Read more >
Using HTML Entity Encode to mitigate XSS vulnerability, then ...
HTML Entity Encode (HTML Encoding) is a commonly deployed escaping/encoding method to mitigate XSS vulnerability as consciousness of XSS is ...
Read more >
The purpose of escaping html entities
You should also then add HTML Encoding when displaying the information on your User Interface. ... That way you prevent SQL injections.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found