Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop query date regex from matching > 4 digit year #4162

Merged
merged 1 commit into from Oct 9, 2022

Conversation

afontenot
Copy link
Contributor

Some queries are ambiguous between dates and numbers, e.g. "2002" could be a year or a number. In order to simplify quering parsing, Quod Libet stores these ambiguous subqueries as the "NumexprNumberOrDate" type.

When parsing a query, Quod Libet will use this type if the string matches a regex for parsing dates. However, before this commit, the regex will match the first four digits of any four or more digit number. This results in a parsing error for large numbers because of the remaining digits after the four that get matched and parsed.

Instead, use a negative lookahead to limit the year part of the date to four digits. Quod Libet will fall back to using an unambiguous number representation for large numbers.

As an alternative, I tried to allow >4 digit years for future-proofing, but a 4 digit year assumption is baked in too deeply, e.g. in Python's strptime function.

Fixes #4161.

Check-list

  • There is a linked issue discussing the motivations for this feature or bugfix
  • Unit tests have been added where possible
  • I've added / updated documentation for any user-facing features.
  • Performance seems to be comparable or better than current master

Some queries are ambiguous between dates and numbers, e.g. "2002" could
be a year or a number. In order to simplify quering parsing, Quod Libet
stores this ambiguous subqueries as the "NumexprNumberOrDate" type.

When parsing a query, Quod Libet will use this type if the string
matches a regex for parsing dates. However, before this commit, the
regex will match the first four digits of any four or more digit number.
This results in a parsing error for large numbers because of the
remaining digits after the four that get matched and parsed.

Instead, use a negative lookahead to limit the year part of the date to
four digits. Quod Libet will fall back to using an unambiguous number
representation for large numbers.

As an alternative, I tried to allow >4 digit years for future-proofing,
but a 4 digit year assumption is baked in too deeply, e.g. in Python's
`strptime` function.

Fixes quodlibet#4161.
@declension declension merged commit 3c85a6b into quodlibet:master Oct 9, 2022
@declension
Copy link
Member

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't compare a numeric tag to any number greater than 4 digits in a search
2 participants