Skip to content

Commit

Permalink
Java: Add test for XSS sanitizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Sauyon Lee committed Aug 4, 2021
1 parent 8a2030a commit 9c35332
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;

Expand Down Expand Up @@ -157,4 +158,9 @@ public static String stringWithNoMediaType(String userControlled) {
return userControlled; // $xss
}

}
@GetMapping(value = "/abc")
public static String sanitizedString(String userControlled) {
return HtmlUtils.htmlEscape(userControlled);
}

}

0 comments on commit 9c35332

Please sign in to comment.