3 ms·
The example in the solution sketch leads me to believe the author is misdirected. URLs have different attack vectors than HTML and have different escaping rules
by CGamesPlay 14y ago
The example in the solution sketch leads me to believe the author is misdirected. URLs have different attack vectors than HTML and have different escaping rules. In the solution sketch given, the HTML might be safe, but I can easily put any parameters I want into the generated URL.
When designing systems like this, each security boundary should be handled separately. Create a URL class that supports escaping fields safely. Create an HTML template engine that supports escaping contents safely. URL.toString will give a guaranteed-safe URL, which can be inserted into a guaranteed-safe attribute later on.
- ufo 14y agoMy impression was that they were trying to go for a more "middle ground" approach to things that made it easy to convert old existing templates (written in less safe dialects like jQuery templates). Since the legacy code allows you to have inline URLs that you put things in you can't force the users to refactor things to generate all the URLs outside the templates.