Skip to content

Escape html special chars #656

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rwillert
Copy link

"> <script>alert('hello');</script> is working for client values and some other templates...
Using html for templates will make the magic. For JSON data and JS templating this step is custom code.
Maybe also will fix #549 and #655

@samrocketman
Copy link

When applying this patch I found that login to the web UI fails.

@samrocketman
Copy link

samrocketman commented May 15, 2025

@rwillert looks like you translate the characters to HTML form but do not reverse the translation when the string gets put to use in the backend. For example, &quot; is not valid shell code and users which might have an ampersand do not match in the database &amp;.

It might be better to base64 encode the user input before storing it in the (JSON) backend and base64 decode when retrieving it.

The encoding would guarantee to not conflict with JSON backend format.

@@ -2,11 +2,11 @@ package router

import (
"errors"
"html/template"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the application.

I'll open a new pull request building on your work and attributing you with a co-authorship.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the PR I verified it works well. #673

samrocketman added a commit to samrocketman/wireguard-ui that referenced this pull request May 21, 2025
* Escaping HTML in several places.
* Adds PreUp config when one didn't exist.
* Adds environment variable support for PreUp and PreDown.

closes ngoduykhanh#549
closes ngoduykhanh#655
closes ngoduykhanh#656

See also
--------

- samrocketman/addons-homeassistant#9

Co-authored-by: Robert Willert <[email protected]>
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.

PostUp, PostDown, PreDown truncated
2 participants