mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Java: Add test for XSS sanitizer
This commit is contained in:
@@ -5,6 +5,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.util.HtmlUtils;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -157,4 +158,9 @@ public class SpringXSS {
|
||||
return userControlled; // $xss
|
||||
}
|
||||
|
||||
}
|
||||
@GetMapping(value = "/abc")
|
||||
public static String sanitizedString(String userControlled) {
|
||||
return HtmlUtils.htmlEscape(userControlled);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user