zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #01252
[Merge] lp:~paul-lucas/zorba/bug-855715 into lp:zorba
Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/bug-855715 into lp:zorba.
Requested reviews:
Paul J. Lucas (paul-lucas)
Matthias Brantner (matthias-brantner)
For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/bug-855715/+merge/79768
Now checking for invalid regex escape sequences.
--
https://code.launchpad.net/~paul-lucas/zorba/bug-855715/+merge/79768
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog 2011-10-12 21:30:46 +0000
+++ ChangeLog 2011-10-19 05:12:24 +0000
@@ -52,6 +52,7 @@
* Added undo for node revalidation
* Fixed bug #872796 (validate-in-place can interfere with other update primitives)
* Fixed bug #872799 (validate-in-place can set incorrect types)
+ * Fixed bug #855715 (Invalid escaped characters in regex not caught)
version 2.0.1
=== modified file 'modules/com/zorba-xquery/www/modules/xqdoc2xhtml/index.xq'
--- modules/com/zorba-xquery/www/modules/xqdoc2xhtml/index.xq 2011-10-07 08:28:43 +0000
+++ modules/com/zorba-xquery/www/modules/xqdoc2xhtml/index.xq 2011-10-19 05:12:24 +0000
@@ -1364,7 +1364,7 @@
fn:concat(fn:substring-before($description,"."),".") else ""
order by $name, $param-number
return
- let $type := replace(normalize-space(substring-after(substring-before($signature, "function"), "declare")),"\%",""),
+ let $type := replace(normalize-space(substring-after(substring-before($signature, "function"), "declare")),"%",""),
$isExternal := ends-with($signature, "external"),
$paramsAndReturn := substring-after($signature,concat(':',$name)),
$external := if(ends-with($signature,"external")) then "external" else ""
=== modified file 'modules/org/expath/ns/file.xq'
--- modules/org/expath/ns/file.xq 2011-10-17 11:49:38 +0000
+++ modules/org/expath/ns/file.xq 2011-10-19 05:12:24 +0000
@@ -624,7 +624,7 @@
declare function file:glob-to-regex(
$pattern as xs:string
) {
- let $pattern := fn:replace($pattern, '(\.|\[|\]|\\|\/|\||\-|\^|\$|\?|\*|\+|\{|\}|\(|\))','\\$1')
+ let $pattern := fn:replace($pattern, '(\.|\[|\]|\\|/|\||\-|\^|\$|\?|\*|\+|\{|\}|\(|\))','\\$1')
let $pattern := fn:replace($pattern, '\\\?', '.')
let $pattern := fn:replace($pattern, '\\\*', '.*')
return
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2011-10-05 18:52:55 +0000
+++ src/diagnostics/diagnostic_en.xml 2011-10-19 05:12:24 +0000
@@ -2393,6 +2393,10 @@
<value>invalid library module</value>
</entry>
+ <entry key="BadRegexEscape_3">
+ <value>"$3": illegal escape character</value>
+ </entry>
+
<entry key="BadPath">
<value>invalid path</value>
</entry>
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2011-10-05 17:49:48 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2011-10-19 05:12:24 +0000
@@ -424,6 +424,7 @@
{ "~BadIterator", "invalid iterator" },
{ "~BadLibraryModule", "invalid library module" },
{ "~BadPath", "invalid path" },
+ { "~BadRegexEscape_3", "\"$3\": illegal escape character" },
{ "~BadStreamState", "bad I/O stream state" },
{ "~BadTokenInBraces_3", "\"$3\": illegal token within { }" },
{ "~BadTraceStream", "trace stream not retrievable using SerializationCallback" },
=== modified file 'src/util/regex.cpp'
--- src/util/regex.cpp 2011-07-18 14:25:21 +0000
+++ src/util/regex.cpp 2011-10-19 05:12:24 +0000
@@ -128,33 +128,69 @@
case 'c': // NameChar
*icu_re += "[" bs_c "]";
continue;
- case 'C': // ^\c
+ case 'C': // [^\c]
*icu_re += "[^" bs_c "]";
continue;
case 'i': // initial NameChar
*icu_re += "[" bs_i "]";
continue;
- case 'I': // ^\i
+ case 'I': // [^\i]
*icu_re += "[^" bs_i "]";
continue;
- default:
- if ( ascii::is_digit( *xq_c ) ) {
- backref_no = *xq_c - '0';
- if ( !backref_no ) // \0 is illegal
- throw INVALID_RE_EXCEPTION( xq_re, ZED( BackRef0Illegal ) );
- if ( in_char_class ) {
- //
- // XQuery 3.0 F&O 5.6.1: Within a character class expression,
- // \ followed by a digit is invalid.
- //
- throw INVALID_RE_EXCEPTION(
- xq_re, ZED( BackRefIllegalInCharClass )
- );
- }
- in_backref = true;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ backref_no = *xq_c - '0';
+ if ( !backref_no ) // \0 is illegal
+ throw INVALID_RE_EXCEPTION( xq_re, ZED( BackRef0Illegal ) );
+ if ( in_char_class ) {
+ //
+ // XQuery 3.0 F&O 5.6.1: Within a character class expression,
+ // \ followed by a digit is invalid.
+ //
+ throw INVALID_RE_EXCEPTION(
+ xq_re, ZED( BackRefIllegalInCharClass )
+ );
}
+ in_backref = true;
+ // no break;
+ case '$':
+ case '(':
+ case ')':
+ case '*':
+ case '+':
+ case '-':
+ case '.':
+ case '?':
+ case 'd': // [0-9]
+ case 'D': // [^\d]
+ case 'n': // newline
+ case 'p': // category escape
+ case 'P': // [^\p]
+ case 'r': // carriage return
+ case 's': // whitespace
+ case 'S': // [^\s]
+ case 't': // tab
+ case 'w': // word char
+ case 'W': // [^\w]
+ case '[':
+ case '\\':
+ case ']':
+ case '^':
+ case '{':
+ case '|':
+ case '}':
*icu_re += '\\';
break;
+ default:
+ throw INVALID_RE_EXCEPTION( xq_re, ZED( BadRegexEscape_3 ), *xq_c );
}
} else {
if ( in_backref ) {
=== modified file 'test/rbkt/Queries/zorba/file/files_pattern_rec1.xq'
--- test/rbkt/Queries/zorba/file/files_pattern_rec1.xq 2011-04-29 22:29:04 +0000
+++ test/rbkt/Queries/zorba/file/files_pattern_rec1.xq 2011-10-19 05:12:24 +0000
@@ -2,9 +2,15 @@
declare variable $path as xs:string external;
+let $sep := file:directory-separator()
+let $escaped_sep :=
+ if ($sep eq "\") then
+ fn:concat("\", $sep)
+ else
+ $sep
let $files := file:list($path, fn:true(), "*dir*")
for $file in $files
where fn:not(fn:matches($file, "\.svn"))
-let $f := fn:replace($file, fn:concat("\", file:directory-separator()), "/")
+let $f := fn:replace($file, $escaped_sep, "/")
order by $f
return <result>{$f}</result>
=== modified file 'test/rbkt/Queries/zorba/file/files_pattern_rec2.xq'
--- test/rbkt/Queries/zorba/file/files_pattern_rec2.xq 2011-04-29 22:29:04 +0000
+++ test/rbkt/Queries/zorba/file/files_pattern_rec2.xq 2011-10-19 05:12:24 +0000
@@ -2,9 +2,15 @@
declare variable $path as xs:string external;
+let $sep := file:directory-separator()
+let $escaped_sep :=
+ if ($sep eq "\") then
+ fn:concat("\", $sep)
+ else
+ $sep
let $files := file:list($path, fn:true(), "*.txt")
for $file in $files
where fn:not(fn:matches($file, "\.svn"))
-let $f := fn:replace($file, fn:concat("\", file:directory-separator()), "/")
+let $f := fn:replace($file, $escaped_sep, "/")
order by $f
return <result>{$f}</result>
Follow ups