Merge lp:~paul-lucas/zorba/bug-855715 into lp:zorba

Proposed by Paul J. Lucas
Status: Merged
Approved by: Paul J. Lucas
Approved revision: 10472
Merged at revision: 10521
Proposed branch: lp:~paul-lucas/zorba/bug-855715
Merge into: lp:zorba
Diff against target: 197 lines (+75/-21)
8 files modified
ChangeLog (+1/-0)
modules/com/zorba-xquery/www/modules/xqdoc2xhtml/index.xq (+1/-1)
modules/org/expath/ns/file.xq (+1/-1)
src/diagnostics/diagnostic_en.xml (+4/-0)
src/diagnostics/pregenerated/dict_en.cpp (+1/-0)
src/util/regex.cpp (+53/-17)
test/rbkt/Queries/zorba/file/files_pattern_rec1.xq (+7/-1)
test/rbkt/Queries/zorba/file/files_pattern_rec2.xq (+7/-1)
To merge this branch: bzr merge lp:~paul-lucas/zorba/bug-855715
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Paul J. Lucas Approve
Review via email: mp+79768@code.launchpad.net

Commit message

Now checking for invalid regex escape sequences.

Description of the change

Now checking for invalid regex escape sequences.

To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-855715-2011-10-19T16-30-14.105Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2011-10-12 21:30:46 +0000
3+++ ChangeLog 2011-10-19 05:12:24 +0000
4@@ -52,6 +52,7 @@
5 * Added undo for node revalidation
6 * Fixed bug #872796 (validate-in-place can interfere with other update primitives)
7 * Fixed bug #872799 (validate-in-place can set incorrect types)
8+ * Fixed bug #855715 (Invalid escaped characters in regex not caught)
9
10 version 2.0.1
11
12
13=== modified file 'modules/com/zorba-xquery/www/modules/xqdoc2xhtml/index.xq'
14--- modules/com/zorba-xquery/www/modules/xqdoc2xhtml/index.xq 2011-10-07 08:28:43 +0000
15+++ modules/com/zorba-xquery/www/modules/xqdoc2xhtml/index.xq 2011-10-19 05:12:24 +0000
16@@ -1364,7 +1364,7 @@
17 fn:concat(fn:substring-before($description,"."),".") else ""
18 order by $name, $param-number
19 return
20- let $type := replace(normalize-space(substring-after(substring-before($signature, "function"), "declare")),"\%",""),
21+ let $type := replace(normalize-space(substring-after(substring-before($signature, "function"), "declare")),"%",""),
22 $isExternal := ends-with($signature, "external"),
23 $paramsAndReturn := substring-after($signature,concat(':',$name)),
24 $external := if(ends-with($signature,"external")) then "external" else ""
25
26=== modified file 'modules/org/expath/ns/file.xq'
27--- modules/org/expath/ns/file.xq 2011-10-17 11:49:38 +0000
28+++ modules/org/expath/ns/file.xq 2011-10-19 05:12:24 +0000
29@@ -624,7 +624,7 @@
30 declare function file:glob-to-regex(
31 $pattern as xs:string
32 ) {
33- let $pattern := fn:replace($pattern, '(\.|\[|\]|\\|\/|\||\-|\^|\$|\?|\*|\+|\{|\}|\(|\))','\\$1')
34+ let $pattern := fn:replace($pattern, '(\.|\[|\]|\\|/|\||\-|\^|\$|\?|\*|\+|\{|\}|\(|\))','\\$1')
35 let $pattern := fn:replace($pattern, '\\\?', '.')
36 let $pattern := fn:replace($pattern, '\\\*', '.*')
37 return
38
39=== modified file 'src/diagnostics/diagnostic_en.xml'
40--- src/diagnostics/diagnostic_en.xml 2011-10-05 18:52:55 +0000
41+++ src/diagnostics/diagnostic_en.xml 2011-10-19 05:12:24 +0000
42@@ -2393,6 +2393,10 @@
43 <value>invalid library module</value>
44 </entry>
45
46+ <entry key="BadRegexEscape_3">
47+ <value>"$3": illegal escape character</value>
48+ </entry>
49+
50 <entry key="BadPath">
51 <value>invalid path</value>
52 </entry>
53
54=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
55--- src/diagnostics/pregenerated/dict_en.cpp 2011-10-05 17:49:48 +0000
56+++ src/diagnostics/pregenerated/dict_en.cpp 2011-10-19 05:12:24 +0000
57@@ -424,6 +424,7 @@
58 { "~BadIterator", "invalid iterator" },
59 { "~BadLibraryModule", "invalid library module" },
60 { "~BadPath", "invalid path" },
61+ { "~BadRegexEscape_3", "\"$3\": illegal escape character" },
62 { "~BadStreamState", "bad I/O stream state" },
63 { "~BadTokenInBraces_3", "\"$3\": illegal token within { }" },
64 { "~BadTraceStream", "trace stream not retrievable using SerializationCallback" },
65
66=== modified file 'src/util/regex.cpp'
67--- src/util/regex.cpp 2011-07-18 14:25:21 +0000
68+++ src/util/regex.cpp 2011-10-19 05:12:24 +0000
69@@ -128,33 +128,69 @@
70 case 'c': // NameChar
71 *icu_re += "[" bs_c "]";
72 continue;
73- case 'C': // ^\c
74+ case 'C': // [^\c]
75 *icu_re += "[^" bs_c "]";
76 continue;
77 case 'i': // initial NameChar
78 *icu_re += "[" bs_i "]";
79 continue;
80- case 'I': // ^\i
81+ case 'I': // [^\i]
82 *icu_re += "[^" bs_i "]";
83 continue;
84- default:
85- if ( ascii::is_digit( *xq_c ) ) {
86- backref_no = *xq_c - '0';
87- if ( !backref_no ) // \0 is illegal
88- throw INVALID_RE_EXCEPTION( xq_re, ZED( BackRef0Illegal ) );
89- if ( in_char_class ) {
90- //
91- // XQuery 3.0 F&O 5.6.1: Within a character class expression,
92- // \ followed by a digit is invalid.
93- //
94- throw INVALID_RE_EXCEPTION(
95- xq_re, ZED( BackRefIllegalInCharClass )
96- );
97- }
98- in_backref = true;
99+ case '0':
100+ case '1':
101+ case '2':
102+ case '3':
103+ case '4':
104+ case '5':
105+ case '6':
106+ case '7':
107+ case '8':
108+ case '9':
109+ backref_no = *xq_c - '0';
110+ if ( !backref_no ) // \0 is illegal
111+ throw INVALID_RE_EXCEPTION( xq_re, ZED( BackRef0Illegal ) );
112+ if ( in_char_class ) {
113+ //
114+ // XQuery 3.0 F&O 5.6.1: Within a character class expression,
115+ // \ followed by a digit is invalid.
116+ //
117+ throw INVALID_RE_EXCEPTION(
118+ xq_re, ZED( BackRefIllegalInCharClass )
119+ );
120 }
121+ in_backref = true;
122+ // no break;
123+ case '$':
124+ case '(':
125+ case ')':
126+ case '*':
127+ case '+':
128+ case '-':
129+ case '.':
130+ case '?':
131+ case 'd': // [0-9]
132+ case 'D': // [^\d]
133+ case 'n': // newline
134+ case 'p': // category escape
135+ case 'P': // [^\p]
136+ case 'r': // carriage return
137+ case 's': // whitespace
138+ case 'S': // [^\s]
139+ case 't': // tab
140+ case 'w': // word char
141+ case 'W': // [^\w]
142+ case '[':
143+ case '\\':
144+ case ']':
145+ case '^':
146+ case '{':
147+ case '|':
148+ case '}':
149 *icu_re += '\\';
150 break;
151+ default:
152+ throw INVALID_RE_EXCEPTION( xq_re, ZED( BadRegexEscape_3 ), *xq_c );
153 }
154 } else {
155 if ( in_backref ) {
156
157=== modified file 'test/rbkt/Queries/zorba/file/files_pattern_rec1.xq'
158--- test/rbkt/Queries/zorba/file/files_pattern_rec1.xq 2011-04-29 22:29:04 +0000
159+++ test/rbkt/Queries/zorba/file/files_pattern_rec1.xq 2011-10-19 05:12:24 +0000
160@@ -2,9 +2,15 @@
161
162 declare variable $path as xs:string external;
163
164+let $sep := file:directory-separator()
165+let $escaped_sep :=
166+ if ($sep eq "\") then
167+ fn:concat("\", $sep)
168+ else
169+ $sep
170 let $files := file:list($path, fn:true(), "*dir*")
171 for $file in $files
172 where fn:not(fn:matches($file, "\.svn"))
173-let $f := fn:replace($file, fn:concat("\", file:directory-separator()), "/")
174+let $f := fn:replace($file, $escaped_sep, "/")
175 order by $f
176 return <result>{$f}</result>
177
178=== modified file 'test/rbkt/Queries/zorba/file/files_pattern_rec2.xq'
179--- test/rbkt/Queries/zorba/file/files_pattern_rec2.xq 2011-04-29 22:29:04 +0000
180+++ test/rbkt/Queries/zorba/file/files_pattern_rec2.xq 2011-10-19 05:12:24 +0000
181@@ -2,9 +2,15 @@
182
183 declare variable $path as xs:string external;
184
185+let $sep := file:directory-separator()
186+let $escaped_sep :=
187+ if ($sep eq "\") then
188+ fn:concat("\", $sep)
189+ else
190+ $sep
191 let $files := file:list($path, fn:true(), "*.txt")
192 for $file in $files
193 where fn:not(fn:matches($file, "\.svn"))
194-let $f := fn:replace($file, fn:concat("\", file:directory-separator()), "/")
195+let $f := fn:replace($file, $escaped_sep, "/")
196 order by $f
197 return <result>{$f}</result>

Subscribers

People subscribed via source and target branches