Add test of various escape functions
authorAndres Freund <[email protected]>
Mon, 10 Feb 2025 15:03:37 +0000 (10:03 -0500)
committerAndres Freund <[email protected]>
Mon, 10 Feb 2025 15:03:37 +0000 (10:03 -0500)
commitac00ff1c96081ea4981f1001209b4719f5cd82ac
treefe3ac31f437d92f052e680dbb74b80f04ec2a396
parent5dc1e42b4fa6a4434afa7d7cdcf0291351a7b873
Add test of various escape functions

As highlighted by the prior commit, writing correct escape functions is less
trivial than one might hope.

This test module tries to verify that different escaping functions behave
reasonably. It e.g. tests:

- Invalidly encoded input to an escape function leads to invalidly encoded
  output

- Trailing incomplete multi-byte characters are handled sensibly

- Escaped strings are parsed as single statement by psql's parser (which
  derives from the backend parser)

There are further tests that would be good to add. But even in the current
state it was rather useful for writing the fix in the prior commit.

Reviewed-by: Noah Misch <[email protected]>
Backpatch-through: 13
Security: CVE-2025-1094
src/test/modules/Makefile
src/test/modules/meson.build
src/test/modules/test_escape/.gitignore [new file with mode: 0644]
src/test/modules/test_escape/Makefile [new file with mode: 0644]
src/test/modules/test_escape/meson.build [new file with mode: 0644]
src/test/modules/test_escape/t/001_test_escape.pl [new file with mode: 0644]
src/test/modules/test_escape/test_escape.c [new file with mode: 0644]
src/tools/pgindent/typedefs.list