You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Up until 0.2.6 (?P<user_agent>[a-zA-Z\d-_]+/[0-9\.]+) was a valid regex. Since 0.2.7 \d does not work and only (?P<user_agent>[a-zA-Z0-9-_]+/[0-9\.]+) works. Is it possible that that is a regression because as far as I understand RE2 it should be valid.
Ug. That is definitely not an (intentionally, IIRC) valid regex, but it looks like the old parser accepted it anyway. The problem is that your syntax is attempting to write a character range, where the end of the range is _ but the beginning of the range is \d. Starting a range with a class itself isn't meaningful, so the parser today returns an error. In general, the - character is always interpreted as indicating a range unless it is escaped or unless it appears at the beginning or end of a character class. e.g., While [\d-_] is invalid, [\d_-] is valid and does what you want.
At the very least, the error message could be better here and should call out the fact that it's trying to interpret a range.
Note that it is also possible that the current behavior is actually undesirable and we might want to be a bit more flexible in allowing - to be treated as a literal - if either end of its range isn't actually a valid start or end of a range.
Oh. That makes a lot of sense 😄 Not sure what most people except from the single dash (literal or range). Stricter interpreting with a more helpful error message does sound good to me.
About the 2nd comment: Not sure if I even need \d at the moment because I am just trying to restrict the types of user agents people use. I can always expand it when people complain 😄
Up until 0.2.6
(?P<user_agent>[a-zA-Z\d-_]+/[0-9\.]+)
was a valid regex. Since 0.2.7\d
does not work and only(?P<user_agent>[a-zA-Z0-9-_]+/[0-9\.]+)
works. Is it possible that that is a regression because as far as I understand RE2 it should be valid.The issue was raised here:
https://gitlab.com/tobias47n9e/wikibase_rs/issues/1
The text was updated successfully, but these errors were encountered: