1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-31 03:21:24 +03:00

Backpatch: Fix tsvector_out() and tsquery_out() to escape backslesh, add test of that.

Patch by Bruce Momjian <bruce@momjian.us>
This commit is contained in:
Teodor Sigaev 2007-11-16 17:09:15 +00:00
parent 011e0efc15
commit 9275f2d34c
4 changed files with 10 additions and 2 deletions

View File

@ -342,6 +342,12 @@ SELECT '''the wether'':dc & '' sKies '':BC & a:d b:a';
'the wether':dc & ' sKies ':BC & a:d b:a 'the wether':dc & ' sKies ':BC & a:d b:a
(1 row) (1 row)
SELECT tsvector_in(tsvector_out($$'\\as' ab\c ab\\c AB\\\c ab\\\\c$$::tsvector)), tsquery_in(tsquery_out($$'\\as'$$::tsquery));
tsvector_in | tsquery_in
----------------------------------------+------------
'\\as' 'abc' 'AB\\c' 'ab\\c' 'ab\\\\c' | '\\as'
(1 row)
select lexize('simple', 'ASD56 hsdkf'); select lexize('simple', 'ASD56 hsdkf');
lexize lexize
----------------- -----------------

View File

@ -723,7 +723,7 @@ infix(INFIX * in, bool first)
in->cur++; in->cur++;
while (*op) while (*op)
{ {
if (*op == '\'') if (*op == '\'' || *op == '\\')
{ {
*(in->cur) = '\\'; *(in->cur) = '\\';
in->cur++; in->cur++;

View File

@ -65,6 +65,8 @@ SELECT '1&(2&(4&(5|!6)))'::tsquery;
SELECT E'1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::tsquery; SELECT E'1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::tsquery;
SELECT '''the wether'':dc & '' sKies '':BC & a:d b:a'; SELECT '''the wether'':dc & '' sKies '':BC & a:d b:a';
SELECT tsvector_in(tsvector_out($$'\\as' ab\c ab\\c AB\\\c ab\\\\c$$::tsvector)), tsquery_in(tsquery_out($$'\\as'$$::tsquery));
select lexize('simple', 'ASD56 hsdkf'); select lexize('simple', 'ASD56 hsdkf');
select lexize('en_stem', 'SKIES Problems identity'); select lexize('en_stem', 'SKIES Problems identity');

View File

@ -520,7 +520,7 @@ tsvector_out(PG_FUNCTION_ARGS)
j = ptr->len; j = ptr->len;
while (j--) while (j--)
{ {
if (*curin == '\'') if (*curin == '\'' || *curin == '\\')
{ {
int4 pos = curout - outbuf; int4 pos = curout - outbuf;