You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Tasssadar (via GitHub)" <gi...@apache.org> on 2025/04/15 06:50:47 UTC
[PR] Fix RegExp.toString generating invalid RE for CHAR and CHAR_RANGE [lucene]
Tasssadar opened a new pull request, #14493:
URL: https://github.com/apache/lucene/pull/14493
The `toString` on regexes that contain a CHAR or CHAR_RANGE has been broken since https://github.com/apache/lucene/commit/1efce5444dd40142c55c5a3a30eeebc7b86796c3 , because ASCII character like `s` becomes `\s`, which parses as character class.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Fix RegExp.toString generating invalid RE for CHAR and CHAR_RANGE [lucene]
Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on PR #14493:
URL: https://github.com/apache/lucene/pull/14493#issuecomment-2804210293
> What would be the right way to get the original input string then, please? Or do you just declare that `RegExp` does not support that?
>
It doesn't have a method to support this. if the feature is really needed, I would be in favor of doing this in the obvious way if possible: just holding a ref to the original string before any parsing.
> Also, it's not just about readability - even as a human, if I see `regex.toString() == "\\s"`, before this fix, I don't know whether it is `s` character or `whitespace` class.
This PR makes it better though. Personally my opinion: the entire `.toString()` should be rewritten from scratch. It was never properly designed to be user-friendly in any way. I still plan to merge your incremental improvement though.
For testing purposes we rely on two things:
- Correct Parse: mostly this is done via `toStringTree()` which returns structured-ish format of the represenation. See TestRegExpParsing.java as example.
- Correct Behavior: mostly this is done via `Automaton` classes which is unambiguous.
Assertions on the `toString()` are mostly just legacy and there's no guarantees about the format of that method AFAIK, so we can change it to be better.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Fix RegExp.toString generating invalid RE for CHAR and CHAR_RANGE [lucene]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #14493:
URL: https://github.com/apache/lucene/pull/14493#issuecomment-2840521041
This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Fix RegExp.toString generating invalid RE for CHAR and CHAR_RANGE [lucene]
Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on PR #14493:
URL: https://github.com/apache/lucene/pull/14493#issuecomment-2804077216
I like the change. We can get fancy and extend it in the future, but the `toString()` today does not do its one job, the output is not readable. This fixes it to be more practical and not try to escape, in unnecessary cases.
Separately: the output of `.toString()` is just that, for humans, and not guaranteed to be reparsable. I can practically guarantee it is a bad idea to do this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [PR] Fix RegExp.toString generating invalid RE for CHAR and CHAR_RANGE [lucene]
Posted by "Tasssadar (via GitHub)" <gi...@apache.org>.
Tasssadar commented on PR #14493:
URL: https://github.com/apache/lucene/pull/14493#issuecomment-2804173363
> Separately: the output of .toString() is just that, for humans, and not guaranteed to be reparsable. I can practically guarantee it is a bad idea to do this.
What would be the right way to get the original input string then, please? Or do you just declare that `RegExp` does not support that?
Also, it's not just about readability - even as a human, if I see `regex.toString() == "\\s"`, before this fix, I don't know whether it is `s` character or `whitespace` class.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org