GithubHelp home page GithubHelp logo

The lang subtags is cleaned about antisamy HOT 5 CLOSED

nahsra avatar nahsra commented on July 4, 2024
The lang subtags is cleaned

from antisamy.

Comments (5)

spassarop avatar spassarop commented on July 4, 2024 1

@LiuXing-R the answer is in the policy. The current definition of lang attribute on every predefined policy is:

<attribute name="lang" description="The 'lang' attribute tells the browser what language the element's attribute values and content are written in">
  <regexp-list>
    <regexp value="[a-zA-Z-]{2,20}"/>
  </regexp-list>
</attribute>

The regex [a-zA-Z-]{2,20} does not include - and that is why is being filtered. As there are MANY ways of writting languages, the easiest (but safe) regex to use would be [a-zA-Z0-9-]{2,20}. Of course it allows languages like ------ but that is not a problem when looking for malicious HTML input. That change on avery policy file would do.

from antisamy.

davewichers avatar davewichers commented on July 4, 2024

@spassarop - Sebastian? Any thoughts here? I have no idea.

from antisamy.

LiuXing-R avatar LiuXing-R commented on July 4, 2024

@spassarop You're right.

The regex [a-zA-Z-]{2,20} does not include - and that is why is being filtered. As there are MANY ways of writting languages, the easiest (but safe) regex to use would be [a-zA-Z0-9-]{2,20}. Of course it allows languages like ------ but that is not a problem when looking for malicious HTML input. That change on avery policy file would do.

@davewichers I'll change the regex to [a-zA-Z0-9-]{2,20} later

from antisamy.

davewichers avatar davewichers commented on July 4, 2024

@LiuXing-R / @spassarop - Isn't the trailing dash after the Z a dash? I tested the original regex at: https://www.freeformatter.com/java-regex-tester.html#ad-output, entering: [a-zA-Z-]{2,20} as the regex, and en-GB as the value and it matched just fine. I don't see that adding digits to the regex hurts anything but it shouldn't fix the issue you reported either.

from antisamy.

spassarop avatar spassarop commented on July 4, 2024

That was my mistake, the trailing dash is not part of the current policies (the PR shows that). I added it for testing (it worked) and left it when I copied that definition to explain.

The digits is because you can express languages like "es-419" too. I've found out about that yesterday, as well as more formats which include lots of letters and dashes. It's just to be more inclusive.

from antisamy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.