File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
main/scala/org/apache/spark/ui
test/scala/org/apache/spark/ui Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ private[spark] object UIUtils extends Logging {
35
35
val TABLE_CLASS_STRIPED = TABLE_CLASS_NOT_STRIPED + " table-striped"
36
36
val TABLE_CLASS_STRIPED_SORTABLE = TABLE_CLASS_STRIPED + " sortable"
37
37
38
- private val NEWLINE_AND_SINGLE_QUOTE_REGEX = " ( \r\n |\n |\r |%0D%0A|%0A|%0D|'|%27)"
38
+ private val NEWLINE_AND_SINGLE_QUOTE_REGEX = raw " (?i)( \r\n|\n|\r|%0D%0A|%0A|%0D|'|%27)" .r
39
39
40
40
// SimpleDateFormat is not thread-safe. Don't expose it to avoid improper use.
41
41
private val dateFormat = new ThreadLocal [SimpleDateFormat ]() {
@@ -544,6 +544,6 @@ private[spark] object UIUtils extends Logging {
544
544
} else {
545
545
// Remove new lines and single quotes, followed by escaping HTML version 4.0
546
546
StringEscapeUtils .escapeHtml4(
547
- requestParameter.replaceAll( NEWLINE_AND_SINGLE_QUOTE_REGEX , " " ))
547
+ NEWLINE_AND_SINGLE_QUOTE_REGEX .replaceAllIn(requestParameter , " " ))
548
548
}
549
549
}
Original file line number Diff line number Diff line change @@ -133,6 +133,13 @@ class UIUtilsSuite extends SparkFunSuite {
133
133
assert(decoded2 === decodeURLParameter(decoded2))
134
134
}
135
135
136
+ test(" SPARK-20393: Prevent newline characters in parameters." ) {
137
+ val encoding = " Encoding:base64%0d%0a%0d%0aPGh0bWw%2bjcmlwdD48L2h0bWw%2b"
138
+ val stripEncoding = " Encoding:base64PGh0bWw%2bjcmlwdD48L2h0bWw%2b"
139
+
140
+ assert(stripEncoding === stripXSS(encoding))
141
+ }
142
+
136
143
test(" SPARK-20393: Prevent script from parameters running on page." ) {
137
144
val scriptAlert = """ >"'><script>alert(401)<%2Fscript>"""
138
145
val stripScriptAlert = " >"><script>alert(401)<%2Fscript>"
You can’t perform that action at this time.
0 commit comments