Skip to content

Commit

Permalink
Sanitize user-input on file name (#17666)
Browse files Browse the repository at this point in the history
* Sanitize user-input on file name

- Sanitize user-input before it get passed into the DOM.
- Prevent things like "<iframe onload=alert(1)></iframe>" from being
executed. This isn't a XSS attack as the server seems to be santizing
the path as well.

Co-authored-by: wxiaoguang <[email protected]>
  • Loading branch information
Gusted and wxiaoguang authored Nov 17, 2021
1 parent 5233051 commit d8a8961
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion web_src/js/features/repo-editor.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {htmlEscape} from 'escape-goat';
import {initMarkupContent} from '../markup/content.js';
import {createCodeEditor} from './codeeditor.js';

Expand Down Expand Up @@ -109,7 +110,7 @@ export function initRepoEditor() {
value = parts[i];
if (i < parts.length - 1) {
if (value.length) {
$(`<span class="section"><a href="#">${value}</a></span>`).insertBefore($(this));
$(`<span class="section"><a href="#">${htmlEscape(value)}</a></span>`).insertBefore($(this));
$('<div class="divider"> / </div>').insertBefore($(this));
}
} else {
Expand Down

0 comments on commit d8a8961

Please sign in to comment.