[SOLVED] Search w/ pipe char throws PDOException

I searched for a TED Talk last night, the search looked like “title | author” (I copied the youtube caption exactly) and I got an error: Could not update headlines (invalid object received - see error console for details).

So I tried “1|2” and that did not error. So I tried “1 | 2” and that gave the error again (“1| 2” and “1 |2” also error). So it looks like the pipe character at the beginning or end of a token causes the error.

Uncaught PDOException: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error in tsquery: "1 & | & 2" in /var/www/html/tt-rss/app/classes/feeds.php:1769 Stack trace: #0 /var/www/html/tt-rss/app/classes/feeds.php(1769): PDO->query('SELECT DISTINCT...') #1 /var/www/html/tt-rss/app/classes/feeds.php(199): Feeds::queryFeedHeadlines(Array) #2 /var/www/html/tt-rss/app/classes/feeds.php(548): Feeds->format_headlines_list(0, NULL, 'adaptive', 30, true, 0, false, true, NULL, false, 'default') #3 /var/www/html/tt-rss/app/backend.php(123): Feeds->view() #4 {main} thrown

The error seems to come from:

AND (tsvector_combined @@ to_tsquery('simple', '1 & | & 2'))

we don’t really support “A or B” searches so pipe should probably be filtered out entirely

either that or rework tokenization entirely which doesn’t sound like a lot of fun

e: idk how annoying would be to not do implicit &-concatenation on postgresql and force everyone to write search queries as “A & B & C” which would allow using |

e2: & also throws an error btw

you know, it’s not so bad. maybe &-concatenation should be removed when using tsquery.

04l9YeBF

in this case plain multiple keyword list produces a syntax error though

a better way would probably be going through all tokens and adding & if necessary (i.e. next token is not a & or |) but it’s such a bother, really


regardless of the concatenation outcome (thoughts?), failing with a fatal error on an invalid query syntax is bad, so i’ve added a workaround:

https://git.tt-rss.org/fox/tt-rss/commit/1cd9b3c866e998e017873eb8b4f08864c4c5f043

That works.

Or wrap the line 1769 in a try/catch and popup a box requesting to restate the search w/o special characters?

Or preemptively zap non-alphanum except “&”?

there’s unfortunately no way to provide feedback like this other than generating a dummy feed output, i think, it seems like too much work

i’d rather not wrap the entire headline query into try-catch because it failing just shouldn’t happen anyway and i’d prefer it to be visible

https://git.tt-rss.org/fox/tt-rss/commit/ccc0315ef0a115fb9111823b351bbcbdf3182f66

a compromise solution i guess

Yes, that gives the user a chance to re-search and give the reason why. Thx!