Best regex to catch XSS (Cross-site Scripting) attack (in Java)?

后端 未结 9 1888
南方客
南方客 2020-12-02 08:49

Jeff actually posted about this in Sanitize HTML. But his example is in C# and I\'m actually more interested in a Java version. Does anyone have a better version for Java? I

9条回答
  •  被撕碎了的回忆
    2020-12-02 09:43

    ^(\s|\w|\d|
    )*?$

    This will validate characters, digits, whitespaces and also the
    tag. If you want more risk you can add more tags like

    ^(\s|\w|\d|
    |
      |<\ul>)*?$

提交回复
热议问题