diff options
author | unknown <jimw@mysql.com> | 2005-02-03 16:07:32 -0800 |
---|---|---|
committer | unknown <jimw@mysql.com> | 2005-02-03 16:07:32 -0800 |
commit | d41473f3c63c4f770f1bb28f1729331d4f780ada (patch) | |
tree | 7212a22c35abcccce68cd7af551d4bb98a3bfcb7 /sql/sql_lex.cc | |
parent | d743b102624bf13207a533a27580ff2d86eb86d0 (diff) | |
download | mariadb-git-d41473f3c63c4f770f1bb28f1729331d4f780ada.tar.gz |
Fix error in parsing string literals containing a backslash followed
by a multi-byte character with a second byte of 0x5c (\). (Bug #8903)
sql/sql_lex.cc:
Fix lex error when multi-byte character containing 0x5c (\) follows a
backslash
mysql-test/t/ctype_sjis.test:
Add regression test for Bug #8303
mysql-test/r/ctype_sjis.result:
Add test results
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r-- | sql/sql_lex.cc | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index ed974a48ad3..d6dcd9ce9ae 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -295,7 +295,18 @@ static char *get_text(LEX *lex) found_escape=1; if (lex->ptr == lex->end_of_query) return 0; - yySkip(); +#ifdef USE_MB + int l; + if (use_mb(cs) && + (l = my_ismbchar(cs, + (const char *)lex->ptr, + (const char *)lex->end_of_query))) { + lex->ptr += l; + continue; + } + else +#endif + yySkip(); } else if (c == sep) { @@ -323,6 +334,10 @@ static char *get_text(LEX *lex) else { uchar *to; + + /* Re-use found_escape for tracking state of escapes */ + found_escape= 0; + for (to=start ; str != end ; str++) { #ifdef USE_MB @@ -336,7 +351,7 @@ static char *get_text(LEX *lex) continue; } #endif - if (*str == '\\' && str+1 != end) + if (!found_escape && *str == '\\' && str+1 != end) { switch(*++str) { case 'n': @@ -362,15 +377,20 @@ static char *get_text(LEX *lex) *to++= '\\'; // remember prefix for wildcard /* Fall through */ default: - *to++ = *str; + found_escape= 1; + str--; break; } } - else if (*str == sep) - *to++= *str++; // Two ' or " + else if (!found_escape && *str == sep) + { + found_escape= 1; + } else + { *to++ = *str; - + found_escape= 0; + } } *to=0; lex->yytoklen=(uint) (to-start); |