adminer icon indicating copy to clipboard operation
adminer copied to clipboard

Fixed string constants and queries splitting.

Open alxivnov opened this issue 1 year ago • 1 comments

\ at the end of string constants breaks string/query splitting. Here is the test:

-- \ at the end of strting query splitting
SELECT 'some''', '\', ';';

SELECT E'some\'', E'\\', E';';

SELECT 'some''', '\', ';', E'some\'', E'\\', E';';

SELECT E'some\'', E'\\', E';', 'some''', '\', ';';

alxivnov avatar Jun 02 '24 09:06 alxivnov

Thanks for sharing, but your fix contains several problems:

  • C-style escapes depends on SQL dialect and server settings.
  • String constants letter E is PostgreSQL specific and is case-insensitive.
  • Added "[^']" rule works only for single quotes, but main cycle detects various types of string quotes.

Here you can find a solution for MySQL and PostgreSQL based on your work (if you are interested): https://github.com/pematon/adminer/commit/aa519b78ca88895cacc8dec0de0fe3c00125b428

peterpp avatar Sep 20 '24 22:09 peterpp

Thanks.

vrana avatar Feb 19 '25 19:02 vrana