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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

escape html #1415

Merged
merged 1 commit into from Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions js/files/circles.files.list.js
Expand Up @@ -124,11 +124,20 @@
},

formatResult: function(circle) {
return circle.name;
return this.escapeHTML(circle.name);
},

formatSelection: function(circle) {
return circle.name;
return this.escapeHTML(circle.name);
},

escapeHTML: function (text) {
return text.toString()
.split('&').join('&')
.split('<').join('&lt;')
.split('>').join('&gt;')
.split('"').join('&quot;')
.split('\'').join('&#039;');
Comment on lines +135 to +140
Copy link

Choose a reason for hiding this comment

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

Suggested change
return text.toString()
.split('&').join('&amp;')
.split('<').join('&lt;')
.split('>').join('&gt;')
.split('"').join('&quot;')
.split('\'').join('&#039;');
const parser = new DOMParser();
const doc = parser.parseFromString(text, 'text/html');
return doc.body.textContent;

Copy link

Choose a reason for hiding this comment

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

This would escape any chars not thought about and handle more edge cases, it however looks okay

Copy link
Member Author

Choose a reason for hiding this comment

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

tried it, it removes text within <> which might be excessive :)

},

sortResults: function(results) {
Expand Down