mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
add global replacements using inverted char classes as a sanitizer for DOM based XSS
This commit is contained in:
@@ -34,7 +34,14 @@ module Shared {
|
||||
class MetacharEscapeSanitizer extends Sanitizer, StringReplaceCall {
|
||||
MetacharEscapeSanitizer() {
|
||||
isGlobal() and
|
||||
RegExp::alwaysMatchesMetaCharacter(getRegExp().getRoot(), ["<", "'", "\""])
|
||||
(
|
||||
RegExp::alwaysMatchesMetaCharacter(getRegExp().getRoot(), ["<", "'", "\""])
|
||||
or
|
||||
// or it's a global inverted char class.
|
||||
getRegExp().getRoot().(RegExpCharacterClass).isInverted()
|
||||
or
|
||||
getRegExp().getRoot().(RegExpQuantifier).getAChild().(RegExpCharacterClass).isInverted()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,4 +85,8 @@
|
||||
|
||||
$("#id").html(anser.ansiToHtml(text)); // NOT OK
|
||||
$("#id").html(new anser().process(text)); // NOT OK
|
||||
|
||||
$("section h1").each(function(){
|
||||
$("nav ul").append("<a href='#" + $(this).text().toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g,'') + "'>Section</a>"); // OK
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user