Skip to content

Commit d8a8961

Browse files
Gustedwxiaoguang
Gusted
andauthored
Sanitize user-input on file name (#17666)
* 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 <wxiaoguang@gmail.com>
1 parent 5233051 commit d8a8961

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

web_src/js/features/repo-editor.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {htmlEscape} from 'escape-goat';
12
import {initMarkupContent} from '../markup/content.js';
23
import {createCodeEditor} from './codeeditor.js';
34

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

0 commit comments

Comments
 (0)