Skip to content

RustPython sre module fail to match HTMLParser regex #3836

Closed

Description

@qingshi163

For the regex:

locatestarttagend_tolerant = re.compile(r"""
  <[a-zA-Z][^\t\n\r\f />\x00]*       # tag name
  (?:[\s/]*                          # optional whitespace before attribute name
    (?:(?<=['"\s/])[^\s/>][^\s/=>]*  # attribute name
      (?:\s*=+\s*                    # value indicator
        (?:'[^']*'                   # LITA-enclosed value
          |"[^"]*"                   # LIT-enclosed value
          |(?!['"])[^>\s]*           # bare value
         )
         (?:\s*,)*                   # possibly followed by a comma
       )?(?:\s|/(?!>))*
     )*
   )?
  \s*                                # trailing whitespace
""", re.VERBOSE)

Until now I find these expr has incorrect results:

p.match("<foo one=1 two=2>") # two=2 not in match
p.match(r"<foo \n one>") # one not in match but correct if not raw string(without r)

Activity

  1. youknowone commented on Jul 19, 2022

    @youknowone
    Member

    minimal reproducible example:

    import re
    
    p = re.compile(
      r"((1)?)*"
    )
    g = p.match("111")
    print(g)
  2. qingshi163 commented on Jul 19, 2022

    @qingshi163
    ContributorAuthor

    Thanks, I am working on sre-engine

  3. fanninpm commented on Jul 28, 2022

    @fanninpm
    Contributor

    Is this solved now?

  4. qingshi163 commented on Jul 29, 2022

    @qingshi163
    ContributorAuthor

    Yes, it is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions