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

Accept more delimiters for filters #1514

Open
heull001 opened this issue Jan 9, 2025 · 1 comment
Open

Accept more delimiters for filters #1514

heull001 opened this issue Jan 9, 2025 · 1 comment

Comments

@heull001
Copy link

heull001 commented Jan 9, 2025

Selfoss accepts only / (forward slash) as delimiter. Php accepts even more.

A delimiter can be any non-alphanumeric, non-backslash, non-whitespace character.
[...]
It is also possible to use bracket style delimiters where the opening and closing brackets are the starting and ending delimiter, respectively. (), {}, [] and <> are all valid bracket style delimiter pairs.
(https://www.php.net/manual/en/regexp.reference.delimiters.php)

In case it is to complecated to check this, I would like to have atleast one more option, because url filters mostly contain slashes which have to be escaped when using slashes as delimiter. When using forexample () as delimiter, this is not required.

@jtojnar
Copy link
Member

jtojnar commented Jan 10, 2025

Thanks for the suggestion.

I introduced the regex filtering syntax as a stop gap for advanced filtering UI.

I limited the number of recognized symbols in anticipation of fixed string filters but I guess using the special characters in fixed string matching will be quite unlikely and we could always introduce special prefix e.g. r# for raw string.

I think few extra special characters will not be a problem for now now, since we only allow a single filter expression. More delimiters will just make the regex filter-matching regex slightly more complex:

if (@preg_match('/^\\/((?<!\\\\)(?:\\\\)*\\/|[^\\/])*\\/$/', $regex) === 0) {

It will be more annoying once we add support for logical operators, when we might want to use parentheses to group operands but I cannot come up with a reason against the other brackets:

if (preg_match('/^(?P<negated>!)?(?:(?P<field>[^:]*):)?(?P<regex>.+)$/', $expression, $match) !== 1) {

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

No branches or pull requests

2 participants