selfoss icon indicating copy to clipboard operation
selfoss copied to clipboard

Accept more delimiters for filters

Open heull001 opened this issue 1 year ago • 1 comments

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.

heull001 avatar Jan 09 '25 14:01 heull001

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:

https://github.com/fossar/selfoss/blob/9bcd66a7b6659b72179504f7d0d8e2710b886833/src/helpers/Filters/RegexFilter.php#L19

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:

https://github.com/fossar/selfoss/blob/9bcd66a7b6659b72179504f7d0d8e2710b886833/src/helpers/Filters/FilterFactory.php#L27

jtojnar avatar Jan 10 '25 08:01 jtojnar