Merge lp:~zorba-coders/zorba/bug-867376 into lp:zorba
- bug-867376
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Chris Hillery | ||||
Approved revision: | 11299 | ||||
Merged at revision: | 11431 | ||||
Proposed branch: | lp:~zorba-coders/zorba/bug-867376 | ||||
Merge into: | lp:zorba | ||||
Diff against target: |
2405 lines (+1391/-162) 40 files modified
ChangeLog (+1/-0) include/zorba/pregenerated/diagnostic_list.h (+6/-0) modules/com/zorba-xquery/www/modules/pregenerated/errors.xq (+16/-1) modules/com/zorba-xquery/www/modules/uri.xq (+99/-4) src/diagnostics/diagnostic_en.xml (+17/-0) src/diagnostics/pregenerated/diagnostic_list.cpp (+9/-0) src/diagnostics/pregenerated/dict_en.cpp (+3/-0) src/diagnostics/qname.cpp (+1/-0) src/functions/pregenerated/func_uris.cpp (+44/-0) src/functions/pregenerated/func_uris.h (+30/-0) src/functions/pregenerated/function_enum.h (+2/-0) src/runtime/pregenerated/iterator_enum.h (+2/-0) src/runtime/spec/uris/uris.xml (+28/-0) src/runtime/uris/pregenerated/uris.cpp (+56/-0) src/runtime/uris/pregenerated/uris.h (+64/-0) src/runtime/uris/uris_impl.cpp (+216/-0) src/runtime/visitors/pregenerated/planiter_visitor.h (+10/-0) src/runtime/visitors/pregenerated/printer_visitor.cpp (+28/-0) src/runtime/visitors/pregenerated/printer_visitor.h (+6/-0) src/unit_tests/test_uri.cpp (+153/-38) src/zorbatypes/URI.cpp (+165/-105) src/zorbatypes/URI.h (+36/-13) test/fots/CMakeLists.txt (+0/-1) test/rbkt/ExpQueryResults/zorba/uris/parse-uri.xml.res (+1/-0) test/rbkt/ExpQueryResults/zorba/uris/serialize-direct-uri.xml.res (+37/-0) test/rbkt/ExpQueryResults/zorba/uris/serialize-uri.xml.res (+44/-0) test/rbkt/Queries/zorba/uris/parse-invalid.spec (+1/-0) test/rbkt/Queries/zorba/uris/parse-invalid.xq (+3/-0) test/rbkt/Queries/zorba/uris/parse-uri.xq (+6/-0) test/rbkt/Queries/zorba/uris/serialize-direct-uri.xq (+211/-0) test/rbkt/Queries/zorba/uris/serialize-uri.xq (+9/-0) test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.spec (+1/-0) test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.xq (+8/-0) test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.spec (+1/-0) test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.xq (+10/-0) test/rbkt/Queries/zorba/uris/serialize-wrong-path1.spec (+1/-0) test/rbkt/Queries/zorba/uris/serialize-wrong-path1.xq (+9/-0) test/rbkt/Queries/zorba/uris/serialize-wrong-path2.spec (+1/-0) test/rbkt/Queries/zorba/uris/serialize-wrong-path2.xq (+10/-0) test/rbkt/Queries/zorba/uris/uri-source.xml (+46/-0) |
||||
To merge this branch: | bzr merge lp:~zorba-coders/zorba/bug-867376 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Matthias Brantner | Approve | ||
Chris Hillery | Approve | ||
Review via email: mp+159233@code.launchpad.net |
Commit message
Added URI processing module.
Description of the change
- Fix for Bug 867376 URI processing module
Matthias Brantner (matthias-brantner) wrote : | # |
Chris Hillery (ceejatec) wrote : | # |
I think actually there are some error conditions that we're not catching currently. For instance, the following input in serialize-
{ "scheme" : "file", "path" : "d:/a/b/c" }
is a non-opaque URI because it has a path, rather than an opaque-part. But it produces the output:
file:d:/a/b/c
which is an opaque URI. I believe that the input is illegal, because a non-opaque URI with a scheme MUST have a path section that begins with a / character. So the above input should actually raise an error.
Chris Hillery (ceejatec) wrote : | # |
Also, currently serialize-
Luis Rodriguez Gonzalez (kuraru) wrote : | # |
> Also, currently serialize-
> serialize-
> URI tests at the end. Did you forget to commit that file?
I checked the expected results in my code and it does have the opaque test case results, I don't know why it failed for you. Anyway, I'm updating the code in this branch with some minor fixes for some of Matthias' comments.
Chris Hillery (ceejatec) wrote : | # |
Hmmm.... weird. Yep, those results are there after all. I'm not sure where they went when I looked at this the first time. Ok then.
Chris Hillery (ceejatec) wrote : | # |
As for the error condition, I've been thinking about it more, and I'm pretty sure that uri:serialize() needs to enforce at least the following rules:
1. You can specify opaque-part, OR some subset of host/port/
2. If you specify opaque-part, scheme is required.
3. If you specify a scheme and a path, then the path MUST start with a / character.
I would suggest introducing a zerr:ZURI0001 "malformed URI components" error message for uri:serialize() which is thrown if any of the above rules are broken, as well as some new test cases for each of them. It might be nice to have separate errors for each, I guess - ZURI0001 "cannot specify opaque-part in conjunction with host/port/
Chris Hillery (ceejatec) wrote : | # |
Also - the header comment for uri.xq is wrong:
(:~
: This module provides string related functions.
:
: @author Matthias Brantner
: @project XDM/atomic
:
:)
Luis Rodriguez Gonzalez (kuraru) wrote : | # |
> As for the error condition, I've been thinking about it more, and I'm pretty
> sure that uri:serialize() needs to enforce at least the following rules:
>
> 1. You can specify opaque-part, OR some subset of host/port/
> info/query. Not both. (Put another way: If opaque-part is specified, then only
> scheme and fragment may be additionally be specified.)
>
> 2. If you specify opaque-part, scheme is required.
>
> 3. If you specify a scheme and a path, then the path MUST start with a /
> character.
>
> I would suggest introducing a zerr:ZURI0001 "malformed URI components" error
> message for uri:serialize() which is thrown if any of the above rules are
> broken, as well as some new test cases for each of them. It might be nice to
> have separate errors for each, I guess - ZURI0001 "cannot specify opaque-part
> in conjunction with host/port/
> when specifying opaque-part", and ZURI0003 "path component of absolute URI
> (ie, one with a scheme) must begin with /".
I will include the 3 different errors for uri:serialize(), Should I leave uri:parse() without any error code?
I see that in the previous function in the same module they use some predefined XQueryErrorCode inside diagnostic_list.h, Should I include my own codes there?
Chris Hillery (ceejatec) wrote : | # |
> I will include the 3 different errors for uri:serialize(), Should I leave
> uri:parse() without any error code?
I'm sure there are some reasonable errors for uri:parse(), but I'm not totally sure what they might be. It's possible that URI.cpp will already throw some exceptions if you try to parse a bogus URI, and that might well be good enough.
Matthias, can you think of any specific error cases that we should test out?
Chris Hillery (ceejatec) wrote : | # |
There are still some test failures. serialize-
More worrying, FOTS/fn-resolve-uri is failing. I'm looking into that one a bit.
Luis Rodriguez Gonzalez (kuraru) wrote : | # |
> > I will include the 3 different errors for uri:serialize(), Should I leave
> > uri:parse() without any error code?
>
> I'm sure there are some reasonable errors for uri:parse(), but I'm not totally
> sure what they might be. It's possible that URI.cpp will already throw some
> exceptions if you try to parse a bogus URI, and that might well be good
> enough.
>
> Matthias, can you think of any specific error cases that we should test out?
Actually you are right, the current underlying library throws some exceptions already.
Luis Rodriguez Gonzalez (kuraru) wrote : | # |
> There are still some test failures. serialize-
> errors, which is good, but the test needs to be adapted for that (split the
> failing cases into separate tests with a .spec file containing the Error: you
> expect).
>
> More worrying, FOTS/fn-resolve-uri is failing. I'm looking into that one a
> bit.
All failing (as expected) cases were moved to individual test cases. Added also a couple of more to test the other 2 errors (ZURI0001 and ZURI0002).
Chris Hillery (ceejatec) wrote : | # |
I believe Luis has addressed all concerns, and I have done some touch-ups as well.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/bug-867376 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-867376-2013-05-
final status was:
1 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Matthias Brantner (matthias-brantner) wrote : | # |
- Could you give an example in the documentation of uri:parse and show a resulting URI object?
- The names of the variables are all upper-case. I know that we don't have any coding conventions for it but the names in the full-text module are all lower-case. Should we be consistent here?
- uri:parse(
1. why?
2. the function documentation doesn't mention that this could be raised
- uri:parse("http://
- one test doesn't seem to succeed in the queue
Luis Rodriguez Gonzalez (kuraru) wrote : | # |
> - Could you give an example in the documentation of uri:parse and show a
> resulting URI object?
Done
> - The names of the variables are all upper-case. I know that we don't have any
> coding conventions for it but the names in the full-text module are all lower-
> case. Should we be consistent here?
Done
> - uri:parse(
> "63": invalid character code-point"
> 1. why?
> 2. the function documentation doesn't mention that this could be raised
> - uri:parse("http://
> "foo.com", "path" : "/bc" }. Should it return the query part as empty in the
> JSON object?
Done. I had to change some inner parts of URI class from protected to public.
> - one test doesn't seem to succeed in the queue
I can't figure out what test case went wrong. In the log it only says that something produced a segment fault, but I don't recognize the code that produced it. How can I find the exact test case name and error?
Chris Hillery (ceejatec) wrote : | # |
I believe all outstanding comments have been addressed; Matthias, one more pass, please?
Matthias Brantner (matthias-brantner) wrote : | # |
I have pushed some final documentation improvements.
Matthias Brantner (matthias-brantner) wrote : | # |
One of the FOTS tests crashes
Please see: http://
On May 2, 2013, at 5:55 PM, Chris Hillery <email address hidden> wrote:
> I believe all outstanding comments have been addressed; Matthias, one more pass, please?
> --
> https:/
> You are reviewing the proposed merge of lp:~zorba-coders/zorba/bug-867376 into lp:zorba.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/bug-867376 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-867376-2013-05-
final status was:
1 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
Chris Hillery (ceejatec) wrote : | # |
> One of the FOTS tests crashes
We already pushed a fix for that one before asking for your re-review (it was an infinite loop eventually causing OOM).
Chris Hillery (ceejatec) wrote : | # |
The last failing test is because Luis changed the constants back to all lower-case, but forgot to change the corresponding usage of those constants in a test case. However, as I just sent to zorba-dev, I personally believe all-caps is a better approach anyway, so I would like to change the module back rather than changing the test. I will wait to see if anyone has any opinions from my email.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
The attempt to merge lp:~zorba-coders/zorba/bug-867376 into lp:zorba failed. Below is the output from the failed tests.
CMake Error at /home/ceej/
Validation queue job bug-867376-2013-05-
final status was:
1 tests did not succeed - changes not commited.
Error in read script: /home/ceej/
- 11299. By Chris Hillery
-
Constants back to all-CAPS, and with explicit type.
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for merge proposal.
Log at: http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue job bug-867376-2013-05-
All tests succeeded!
Preview Diff
1 | === modified file 'ChangeLog' | |||
2 | --- ChangeLog 2013-05-01 03:58:31 +0000 | |||
3 | +++ ChangeLog 2013-05-03 23:21:27 +0000 | |||
4 | @@ -104,6 +104,7 @@ | |||
5 | 104 | * Fixed bug #1023362 (xsi:type attribute ignored during validation) | 104 | * Fixed bug #1023362 (xsi:type attribute ignored during validation) |
6 | 105 | * Fixed bug #1025564 (Deprecate -f argument to zorbacmd) | 105 | * Fixed bug #1025564 (Deprecate -f argument to zorbacmd) |
7 | 106 | * Fixed bug #1082740 (support for INF and -INF values in fn:subsequence function). | 106 | * Fixed bug #1082740 (support for INF and -INF values in fn:subsequence function). |
8 | 107 | * Fixed bug #867376 (uri:parse() and uri:serialize()) | ||
9 | 107 | 108 | ||
10 | 108 | 109 | ||
11 | 109 | version 2.8 | 110 | version 2.8 |
12 | 110 | 111 | ||
13 | === modified file 'include/zorba/pregenerated/diagnostic_list.h' | |||
14 | --- include/zorba/pregenerated/diagnostic_list.h 2013-05-02 10:19:11 +0000 | |||
15 | +++ include/zorba/pregenerated/diagnostic_list.h 2013-05-03 23:21:27 +0000 | |||
16 | @@ -882,6 +882,12 @@ | |||
17 | 882 | 882 | ||
18 | 883 | extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0008_BAD_VALUE; | 883 | extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZJSE0008_BAD_VALUE; |
19 | 884 | 884 | ||
20 | 885 | extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZURI0001_OPAQUE_WITH_OTHERS; | ||
21 | 886 | |||
22 | 887 | extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZURI0002_SCHEME_REQUIRED_FOR_OPAQUE; | ||
23 | 888 | |||
24 | 889 | extern ZORBA_DLL_PUBLIC ZorbaErrorCode ZURI0003_SLASH_NEEDED_FOR_ABSOLUTE_URI; | ||
25 | 890 | |||
26 | 885 | } // namespace zerr | 891 | } // namespace zerr |
27 | 886 | 892 | ||
28 | 887 | namespace jerr { | 893 | namespace jerr { |
29 | 888 | 894 | ||
30 | === modified file 'modules/com/zorba-xquery/www/modules/pregenerated/errors.xq' | |||
31 | --- modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2013-03-06 00:18:36 +0000 | |||
32 | +++ modules/com/zorba-xquery/www/modules/pregenerated/errors.xq 2013-05-03 23:21:27 +0000 | |||
33 | @@ -977,4 +977,19 @@ | |||
34 | 977 | 977 | ||
35 | 978 | (:~ | 978 | (:~ |
36 | 979 | :) | 979 | :) |
37 | 980 | declare variable $zerr:ZJSE0008 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0008"); | ||
38 | 981 | \ No newline at end of file | 980 | \ No newline at end of file |
39 | 981 | declare variable $zerr:ZJSE0008 as xs:QName := fn:QName($zerr:NS, "zerr:ZJSE0008"); | ||
40 | 982 | |||
41 | 983 | (:~ | ||
42 | 984 | :If the opaque-part section of the URI was specified in conjuction with other non-opaque parts. | ||
43 | 985 | :) | ||
44 | 986 | declare variable $zerr:ZURI0001 as xs:QName := fn:QName($zerr:NS, "zerr:ZURI0001"); | ||
45 | 987 | |||
46 | 988 | (:~ | ||
47 | 989 | :If an opaque-part section was specified without a scheme section. | ||
48 | 990 | :) | ||
49 | 991 | declare variable $zerr:ZURI0002 as xs:QName := fn:QName($zerr:NS, "zerr:ZURI0002"); | ||
50 | 992 | |||
51 | 993 | (:~ | ||
52 | 994 | :If an absolute URI is specified with a path that does not start with slash ("/"). | ||
53 | 995 | :) | ||
54 | 996 | declare variable $zerr:ZURI0003 as xs:QName := fn:QName($zerr:NS, "zerr:ZURI0003"); | ||
55 | 982 | \ No newline at end of file | 997 | \ No newline at end of file |
56 | 983 | 998 | ||
57 | === modified file 'modules/com/zorba-xquery/www/modules/uri.xq' | |||
58 | --- modules/com/zorba-xquery/www/modules/uri.xq 2013-02-07 17:24:36 +0000 | |||
59 | +++ modules/com/zorba-xquery/www/modules/uri.xq 2013-05-03 23:21:27 +0000 | |||
60 | @@ -1,4 +1,4 @@ | |||
62 | 1 | xquery version "1.0"; | 1 | xquery version "3.0"; |
63 | 2 | 2 | ||
64 | 3 | (: | 3 | (: |
65 | 4 | : Copyright 2006-2012 The FLWOR Foundation. | 4 | : Copyright 2006-2012 The FLWOR Foundation. |
66 | @@ -17,20 +17,71 @@ | |||
67 | 17 | :) | 17 | :) |
68 | 18 | 18 | ||
69 | 19 | (:~ | 19 | (:~ |
71 | 20 | : This module provides string related functions. | 20 | : This module provides functions for processing URIs and URLs. |
72 | 21 | : | 21 | : |
74 | 22 | : @author Matthias Brantner | 22 | : @author Matthias Brantner, Luis Rodriguez Gonzalez |
75 | 23 | : @project XDM/atomic | 23 | : @project XDM/atomic |
76 | 24 | : | 24 | : |
77 | 25 | :) | 25 | :) |
78 | 26 | module namespace uri = "http://www.zorba-xquery.com/modules/uri"; | 26 | module namespace uri = "http://www.zorba-xquery.com/modules/uri"; |
79 | 27 | 27 | ||
80 | 28 | declare namespace zerr = "http://www.zorba-xquery.com/errors"; | 28 | declare namespace zerr = "http://www.zorba-xquery.com/errors"; |
81 | 29 | |||
82 | 30 | declare namespace ver = "http://www.zorba-xquery.com/options/versioning"; | 29 | declare namespace ver = "http://www.zorba-xquery.com/options/versioning"; |
83 | 31 | declare option ver:module-version "1.0"; | 30 | declare option ver:module-version "1.0"; |
84 | 32 | 31 | ||
85 | 33 | (:~ | 32 | (:~ |
86 | 33 | : Constant for the "scheme" part of a URI object. | ||
87 | 34 | :) | ||
88 | 35 | declare variable $uri:SCHEME as xs:string := "scheme"; | ||
89 | 36 | |||
90 | 37 | (:~ | ||
91 | 38 | : Constant for the "authority" part of a URI object. | ||
92 | 39 | :) | ||
93 | 40 | declare variable $uri:AUTHORITY as xs:string := "authority"; | ||
94 | 41 | |||
95 | 42 | (:~ | ||
96 | 43 | : Constant for the "user-info" part of a URI object. | ||
97 | 44 | :) | ||
98 | 45 | declare variable $uri:USER-INFO as xs:string := "user-info"; | ||
99 | 46 | |||
100 | 47 | (:~ | ||
101 | 48 | : Constant for the "host" part of a URI object. | ||
102 | 49 | :) | ||
103 | 50 | declare variable $uri:HOST as xs:string := "host"; | ||
104 | 51 | |||
105 | 52 | (:~ | ||
106 | 53 | : Constant for the "port" part of a URI object. | ||
107 | 54 | :) | ||
108 | 55 | declare variable $uri:PORT as xs:string := "port"; | ||
109 | 56 | |||
110 | 57 | (:~ | ||
111 | 58 | : Constant for the "path" part of a URI object. | ||
112 | 59 | :) | ||
113 | 60 | declare variable $uri:PATH as xs:string := "path"; | ||
114 | 61 | |||
115 | 62 | (:~ | ||
116 | 63 | : Constant for the "query" part of a URI object. | ||
117 | 64 | :) | ||
118 | 65 | declare variable $uri:QUERY as xs:string := "query"; | ||
119 | 66 | |||
120 | 67 | (:~ | ||
121 | 68 | : Constant for the "fragment" part of a URI object. | ||
122 | 69 | :) | ||
123 | 70 | declare variable $uri:FRAGMENT as xs:string := "fragment"; | ||
124 | 71 | |||
125 | 72 | (:~ | ||
126 | 73 | : Constant for the "opaque-part" part of a URI object. | ||
127 | 74 | : | ||
128 | 75 | : If this is set in a URI object, then none of $uri:PATH, $uri:HOST, | ||
129 | 76 | : $uri:PORT, $uri:USER-INFO, or : $uri:QUERY may be specified. | ||
130 | 77 | : | ||
131 | 78 | : If this is set in a URI object, $uri:SCHEME must also be specified | ||
132 | 79 | : (ie, it must be an absolute URI). | ||
133 | 80 | :) | ||
134 | 81 | declare variable $uri:OPAQUE-PART as xs:string := "opaque-part"; | ||
135 | 82 | |||
136 | 83 | |||
137 | 84 | (:~ | ||
138 | 34 | : Percent-decodes (aka URL decoding) the given string. | 85 | : Percent-decodes (aka URL decoding) the given string. |
139 | 35 | : | 86 | : |
140 | 36 | : All percent encoded octets will be translated into their | 87 | : All percent encoded octets will be translated into their |
141 | @@ -106,3 +157,47 @@ | |||
142 | 106 | $s as xs:string, | 157 | $s as xs:string, |
143 | 107 | $decode-plus as xs:boolean, | 158 | $decode-plus as xs:boolean, |
144 | 108 | $charset as xs:string) as xs:string external; | 159 | $charset as xs:string) as xs:string external; |
145 | 160 | |||
146 | 161 | (:~ | ||
147 | 162 | : Parses the URI passed as string. The returned object | ||
148 | 163 | : contains only members with field names declared as constants in | ||
149 | 164 | : this module. | ||
150 | 165 | : | ||
151 | 166 | : For example, | ||
152 | 167 | : <code> | ||
153 | 168 | : let my-uri := "http://www.my.project.com/a/b/c?user=john;pass=1234#profile" | ||
154 | 169 | : return uri:parse(my-uri) | ||
155 | 170 | : </code> | ||
156 | 171 | : | ||
157 | 172 | : returns | ||
158 | 173 | : <code> | ||
159 | 174 | : { "squeme" : "http", "host" : "www.my.project.com", "path" : "/a/b/c", | ||
160 | 175 | : "query" : "user=john;pass=123", "fragment" : "profile" } | ||
161 | 176 | : </code> | ||
162 | 177 | : | ||
163 | 178 | : @param $uri the URI to parse | ||
164 | 179 | : | ||
165 | 180 | : @return the JSON object | ||
166 | 181 | : | ||
167 | 182 | : @error err:XQST0046 if the URI is textually invalid | ||
168 | 183 | :) | ||
169 | 184 | declare function uri:parse( | ||
170 | 185 | $uri as xs:string) as object() external; | ||
171 | 186 | |||
172 | 187 | (:~ | ||
173 | 188 | : Serialize the URI passed as object into a string. | ||
174 | 189 | : | ||
175 | 190 | : @param $uri the object representing the URI | ||
176 | 191 | : | ||
177 | 192 | : @return the URI as string | ||
178 | 193 | : | ||
179 | 194 | : @error zerr:ZURI0001 if opaque part is specified in conjunction with | ||
180 | 195 | : host/port/path/user-info/query. | ||
181 | 196 | : | ||
182 | 197 | : @error zerr:ZURI0002 if opaque part is present but no scheme is present. | ||
183 | 198 | : | ||
184 | 199 | : @error zerr:ZURI0003 if a path component for an absolute URI | ||
185 | 200 | : doesn't start with "/". | ||
186 | 201 | :) | ||
187 | 202 | declare function uri:serialize( | ||
188 | 203 | $uri as object()) as xs:string external; | ||
189 | 109 | 204 | ||
190 | === modified file 'src/diagnostics/diagnostic_en.xml' | |||
191 | --- src/diagnostics/diagnostic_en.xml 2013-05-02 10:19:11 +0000 | |||
192 | +++ src/diagnostics/diagnostic_en.xml 2013-05-03 23:21:27 +0000 | |||
193 | @@ -3123,6 +3123,23 @@ | |||
194 | 3123 | <diagnostic code="ZJSE0008" name="BAD_VALUE"> | 3123 | <diagnostic code="ZJSE0008" name="BAD_VALUE"> |
195 | 3124 | <value>"$1": illegal value for JSON type "$2"</value> | 3124 | <value>"$1": illegal value for JSON type "$2"</value> |
196 | 3125 | </diagnostic> | 3125 | </diagnostic> |
197 | 3126 | |||
198 | 3127 | <!-- /////////// URI procesing errors ///////////////////////////////// --> | ||
199 | 3128 | |||
200 | 3129 | <diagnostic code="ZURI0001" name="OPAQUE_WITH_OTHERS"> | ||
201 | 3130 | <comment>If the opaque-part section of the URI was specified in conjuction with other non-opaque parts.</comment> | ||
202 | 3131 | <value>cannot specify opaque-part in conjunction with host/port/path/user-info/query</value> | ||
203 | 3132 | </diagnostic> | ||
204 | 3133 | |||
205 | 3134 | <diagnostic code="ZURI0002" name="SCHEME_REQUIRED_FOR_OPAQUE"> | ||
206 | 3135 | <comment>If an opaque-part section was specified without a scheme section.</comment> | ||
207 | 3136 | <value>scheme required when specifying opaque-part</value> | ||
208 | 3137 | </diagnostic> | ||
209 | 3138 | |||
210 | 3139 | <diagnostic code="ZURI0003" name="SLASH_NEEDED_FOR_ABSOLUTE_URI"> | ||
211 | 3140 | <comment>If an absolute URI is specified with a path that does not start with slash ("/").</comment> | ||
212 | 3141 | <value>path component of absolute URI must begin with /</value> | ||
213 | 3142 | </diagnostic> | ||
214 | 3126 | 3143 | ||
215 | 3127 | </namespace> | 3144 | </namespace> |
216 | 3128 | 3145 | ||
217 | 3129 | 3146 | ||
218 | === modified file 'src/diagnostics/pregenerated/diagnostic_list.cpp' | |||
219 | --- src/diagnostics/pregenerated/diagnostic_list.cpp 2013-05-02 10:19:11 +0000 | |||
220 | +++ src/diagnostics/pregenerated/diagnostic_list.cpp 2013-05-03 23:21:27 +0000 | |||
221 | @@ -1301,6 +1301,15 @@ | |||
222 | 1301 | ZorbaErrorCode ZJSE0008_BAD_VALUE( "ZJSE0008" ); | 1301 | ZorbaErrorCode ZJSE0008_BAD_VALUE( "ZJSE0008" ); |
223 | 1302 | 1302 | ||
224 | 1303 | 1303 | ||
225 | 1304 | ZorbaErrorCode ZURI0001_OPAQUE_WITH_OTHERS( "ZURI0001" ); | ||
226 | 1305 | |||
227 | 1306 | |||
228 | 1307 | ZorbaErrorCode ZURI0002_SCHEME_REQUIRED_FOR_OPAQUE( "ZURI0002" ); | ||
229 | 1308 | |||
230 | 1309 | |||
231 | 1310 | ZorbaErrorCode ZURI0003_SLASH_NEEDED_FOR_ABSOLUTE_URI( "ZURI0003" ); | ||
232 | 1311 | |||
233 | 1312 | |||
234 | 1304 | } // namespace zerr | 1313 | } // namespace zerr |
235 | 1305 | 1314 | ||
236 | 1306 | namespace jerr { | 1315 | namespace jerr { |
237 | 1307 | 1316 | ||
238 | === modified file 'src/diagnostics/pregenerated/dict_en.cpp' | |||
239 | --- src/diagnostics/pregenerated/dict_en.cpp 2013-05-02 10:19:11 +0000 | |||
240 | +++ src/diagnostics/pregenerated/dict_en.cpp 2013-05-03 23:21:27 +0000 | |||
241 | @@ -488,6 +488,9 @@ | |||
242 | 488 | { "ZSTR0060", "\"$1\": value out of range${ 2}" }, | 488 | { "ZSTR0060", "\"$1\": value out of range${ 2}" }, |
243 | 489 | { "ZSTR0065", "Zorba did not close properly, objects may still in memory.\\n$1 referenced URI(s) remain in the string pool.\\nFor help avoiding this message please refer to http://www.zorba-xquery.com/html/documentation in section General Architecture -> Memory Leaks." }, | 489 | { "ZSTR0065", "Zorba did not close properly, objects may still in memory.\\n$1 referenced URI(s) remain in the string pool.\\nFor help avoiding this message please refer to http://www.zorba-xquery.com/html/documentation in section General Architecture -> Memory Leaks." }, |
244 | 490 | { "ZSTR0066", "$1: does not reference a node in collection $2" }, | 490 | { "ZSTR0066", "$1: does not reference a node in collection $2" }, |
245 | 491 | { "ZURI0001", "cannot specify opaque-part in conjunction with host/port/path/user-info/query" }, | ||
246 | 492 | { "ZURI0002", "scheme required when specifying opaque-part" }, | ||
247 | 493 | { "ZURI0003", "path component of absolute URI must begin with /" }, | ||
248 | 491 | { "ZWST0002", "\"$1\": unknown or unsupported annotation" }, | 494 | { "ZWST0002", "\"$1\": unknown or unsupported annotation" }, |
249 | 492 | { "ZWST0003", "\"$1\": function declared sequential, but has non-sequential body" }, | 495 | { "ZWST0003", "\"$1\": function declared sequential, but has non-sequential body" }, |
250 | 493 | { "ZWST0004", "sequential FLWOR expr may not have the semantics you expect" }, | 496 | { "ZWST0004", "sequential FLWOR expr may not have the semantics you expect" }, |
251 | 494 | 497 | ||
252 | === modified file 'src/diagnostics/qname.cpp' | |||
253 | --- src/diagnostics/qname.cpp 2013-02-07 17:24:36 +0000 | |||
254 | +++ src/diagnostics/qname.cpp 2013-05-03 23:21:27 +0000 | |||
255 | @@ -125,6 +125,7 @@ | |||
256 | 125 | case 'O': return ZORBA_OS; | 125 | case 'O': return ZORBA_OS; |
257 | 126 | case 'S': return ZORBA_STORE; | 126 | case 'S': return ZORBA_STORE; |
258 | 127 | case 'X': return ZORBA_XQP; | 127 | case 'X': return ZORBA_XQP; |
259 | 128 | case 'U': return ZORBA_CORE_MODULE; | ||
260 | 128 | 129 | ||
261 | 129 | default : ZORBA_ASSERT( false ); | 130 | default : ZORBA_ASSERT( false ); |
262 | 130 | } | 131 | } |
263 | 131 | 132 | ||
264 | === modified file 'src/functions/pregenerated/func_uris.cpp' | |||
265 | --- src/functions/pregenerated/func_uris.cpp 2013-03-05 23:11:50 +0000 | |||
266 | +++ src/functions/pregenerated/func_uris.cpp 2013-05-03 23:21:27 +0000 | |||
267 | @@ -41,6 +41,26 @@ | |||
268 | 41 | return new DecodeURIIterator(sctx, loc, argv); | 41 | return new DecodeURIIterator(sctx, loc, argv); |
269 | 42 | } | 42 | } |
270 | 43 | 43 | ||
271 | 44 | PlanIter_t fn_zorba_uri_parse::codegen( | ||
272 | 45 | CompilerCB*, | ||
273 | 46 | static_context* sctx, | ||
274 | 47 | const QueryLoc& loc, | ||
275 | 48 | std::vector<PlanIter_t>& argv, | ||
276 | 49 | expr& ann) const | ||
277 | 50 | { | ||
278 | 51 | return new ParseURIIterator(sctx, loc, argv); | ||
279 | 52 | } | ||
280 | 53 | |||
281 | 54 | PlanIter_t fn_zorba_uri_serialize::codegen( | ||
282 | 55 | CompilerCB*, | ||
283 | 56 | static_context* sctx, | ||
284 | 57 | const QueryLoc& loc, | ||
285 | 58 | std::vector<PlanIter_t>& argv, | ||
286 | 59 | expr& ann) const | ||
287 | 60 | { | ||
288 | 61 | return new SerializeURIIterator(sctx, loc, argv); | ||
289 | 62 | } | ||
290 | 63 | |||
291 | 44 | void populate_context_uris(static_context* sctx) | 64 | void populate_context_uris(static_context* sctx) |
292 | 45 | { | 65 | { |
293 | 46 | 66 | ||
294 | @@ -56,6 +76,30 @@ | |||
295 | 56 | 76 | ||
296 | 57 | } | 77 | } |
297 | 58 | 78 | ||
298 | 79 | |||
299 | 80 | |||
300 | 81 | |||
301 | 82 | { | ||
302 | 83 | DECL_WITH_KIND(sctx, fn_zorba_uri_parse, | ||
303 | 84 | (createQName("http://www.zorba-xquery.com/modules/uri","","parse"), | ||
304 | 85 | GENV_TYPESYSTEM.STRING_TYPE_ONE, | ||
305 | 86 | GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE), | ||
306 | 87 | FunctionConsts::FN_ZORBA_URI_PARSE_1); | ||
307 | 88 | |||
308 | 89 | } | ||
309 | 90 | |||
310 | 91 | |||
311 | 92 | |||
312 | 93 | |||
313 | 94 | { | ||
314 | 95 | DECL_WITH_KIND(sctx, fn_zorba_uri_serialize, | ||
315 | 96 | (createQName("http://www.zorba-xquery.com/modules/uri","","serialize"), | ||
316 | 97 | GENV_TYPESYSTEM.JSON_OBJECT_TYPE_ONE, | ||
317 | 98 | GENV_TYPESYSTEM.STRING_TYPE_ONE), | ||
318 | 99 | FunctionConsts::FN_ZORBA_URI_SERIALIZE_1); | ||
319 | 100 | |||
320 | 101 | } | ||
321 | 102 | |||
322 | 59 | } | 103 | } |
323 | 60 | 104 | ||
324 | 61 | 105 | ||
325 | 62 | 106 | ||
326 | === modified file 'src/functions/pregenerated/func_uris.h' | |||
327 | --- src/functions/pregenerated/func_uris.h 2013-03-05 23:11:50 +0000 | |||
328 | +++ src/functions/pregenerated/func_uris.h 2013-05-03 23:21:27 +0000 | |||
329 | @@ -53,6 +53,36 @@ | |||
330 | 53 | }; | 53 | }; |
331 | 54 | 54 | ||
332 | 55 | 55 | ||
333 | 56 | //fn-zorba-uri:parse | ||
334 | 57 | class fn_zorba_uri_parse : public function | ||
335 | 58 | { | ||
336 | 59 | public: | ||
337 | 60 | fn_zorba_uri_parse(const signature& sig, FunctionConsts::FunctionKind kind) | ||
338 | 61 | : | ||
339 | 62 | function(sig, kind) | ||
340 | 63 | { | ||
341 | 64 | |||
342 | 65 | } | ||
343 | 66 | |||
344 | 67 | CODEGEN_DECL(); | ||
345 | 68 | }; | ||
346 | 69 | |||
347 | 70 | |||
348 | 71 | //fn-zorba-uri:serialize | ||
349 | 72 | class fn_zorba_uri_serialize : public function | ||
350 | 73 | { | ||
351 | 74 | public: | ||
352 | 75 | fn_zorba_uri_serialize(const signature& sig, FunctionConsts::FunctionKind kind) | ||
353 | 76 | : | ||
354 | 77 | function(sig, kind) | ||
355 | 78 | { | ||
356 | 79 | |||
357 | 80 | } | ||
358 | 81 | |||
359 | 82 | CODEGEN_DECL(); | ||
360 | 83 | }; | ||
361 | 84 | |||
362 | 85 | |||
363 | 56 | } //namespace zorba | 86 | } //namespace zorba |
364 | 57 | 87 | ||
365 | 58 | 88 | ||
366 | 59 | 89 | ||
367 | === modified file 'src/functions/pregenerated/function_enum.h' | |||
368 | --- src/functions/pregenerated/function_enum.h 2013-04-10 21:01:35 +0000 | |||
369 | +++ src/functions/pregenerated/function_enum.h 2013-05-03 23:21:27 +0000 | |||
370 | @@ -496,6 +496,8 @@ | |||
371 | 496 | FN_ZORBA_STRING_IS_STREAMABLE_1, | 496 | FN_ZORBA_STRING_IS_STREAMABLE_1, |
372 | 497 | FN_ZORBA_STRING_SPLIT_2, | 497 | FN_ZORBA_STRING_SPLIT_2, |
373 | 498 | FN_ZORBA_URI_DECODE_3, | 498 | FN_ZORBA_URI_DECODE_3, |
374 | 499 | FN_ZORBA_URI_PARSE_1, | ||
375 | 500 | FN_ZORBA_URI_SERIALIZE_1, | ||
376 | 499 | FN_ZORBA_XQDOC_XQDOC_CONTENT_IMPL_2, | 501 | FN_ZORBA_XQDOC_XQDOC_CONTENT_IMPL_2, |
377 | 500 | FN_ZORBA_XQDOC_XQDOC_CONTENT_OPTIONS_IMPL_3, | 502 | FN_ZORBA_XQDOC_XQDOC_CONTENT_OPTIONS_IMPL_3, |
378 | 501 | 503 | ||
379 | 502 | 504 | ||
380 | === modified file 'src/runtime/pregenerated/iterator_enum.h' | |||
381 | --- src/runtime/pregenerated/iterator_enum.h 2013-03-15 08:22:41 +0000 | |||
382 | +++ src/runtime/pregenerated/iterator_enum.h 2013-05-03 23:21:27 +0000 | |||
383 | @@ -369,6 +369,8 @@ | |||
384 | 369 | TYPE_StringIsStreamableIterator, | 369 | TYPE_StringIsStreamableIterator, |
385 | 370 | TYPE_StringSplitIterator, | 370 | TYPE_StringSplitIterator, |
386 | 371 | TYPE_DecodeURIIterator, | 371 | TYPE_DecodeURIIterator, |
387 | 372 | TYPE_ParseURIIterator, | ||
388 | 373 | TYPE_SerializeURIIterator, | ||
389 | 372 | TYPE_XQDocContentIterator, | 374 | TYPE_XQDocContentIterator, |
390 | 373 | 375 | ||
391 | 374 | 376 | ||
392 | 375 | 377 | ||
393 | === modified file 'src/runtime/spec/uris/uris.xml' | |||
394 | --- src/runtime/spec/uris/uris.xml 2013-02-07 17:24:36 +0000 | |||
395 | +++ src/runtime/spec/uris/uris.xml 2013-05-03 23:21:27 +0000 | |||
396 | @@ -37,4 +37,32 @@ | |||
397 | 37 | </zorba:function> | 37 | </zorba:function> |
398 | 38 | </zorba:iterator> | 38 | </zorba:iterator> |
399 | 39 | 39 | ||
400 | 40 | <zorba:iterator name="ParseURIIterator"> | ||
401 | 41 | |||
402 | 42 | <zorba:description author="Zorba Team"> | ||
403 | 43 | uri:parse | ||
404 | 44 | </zorba:description> | ||
405 | 45 | |||
406 | 46 | <zorba:function> | ||
407 | 47 | <zorba:signature localname="parse" prefix="fn-zorba-uri"> | ||
408 | 48 | <zorba:param>xs:string</zorba:param> | ||
409 | 49 | <zorba:output>object()</zorba:output> | ||
410 | 50 | </zorba:signature> | ||
411 | 51 | </zorba:function> | ||
412 | 52 | </zorba:iterator> | ||
413 | 53 | |||
414 | 54 | <zorba:iterator name="SerializeURIIterator"> | ||
415 | 55 | |||
416 | 56 | <zorba:description author="Zorba Team"> | ||
417 | 57 | uri:serialize | ||
418 | 58 | </zorba:description> | ||
419 | 59 | |||
420 | 60 | <zorba:function> | ||
421 | 61 | <zorba:signature localname="serialize" prefix="fn-zorba-uri"> | ||
422 | 62 | <zorba:param>object()</zorba:param> | ||
423 | 63 | <zorba:output>xs:string</zorba:output> | ||
424 | 64 | </zorba:signature> | ||
425 | 65 | </zorba:function> | ||
426 | 66 | </zorba:iterator> | ||
427 | 67 | |||
428 | 40 | </zorba:iterators> | 68 | </zorba:iterators> |
429 | 41 | 69 | ||
430 | === modified file 'src/runtime/uris/pregenerated/uris.cpp' | |||
431 | --- src/runtime/uris/pregenerated/uris.cpp 2013-03-05 23:11:50 +0000 | |||
432 | +++ src/runtime/uris/pregenerated/uris.cpp 2013-05-03 23:21:27 +0000 | |||
433 | @@ -60,6 +60,62 @@ | |||
434 | 60 | // </DecodeURIIterator> | 60 | // </DecodeURIIterator> |
435 | 61 | 61 | ||
436 | 62 | 62 | ||
437 | 63 | // <ParseURIIterator> | ||
438 | 64 | SERIALIZABLE_CLASS_VERSIONS(ParseURIIterator) | ||
439 | 65 | |||
440 | 66 | void ParseURIIterator::serialize(::zorba::serialization::Archiver& ar) | ||
441 | 67 | { | ||
442 | 68 | serialize_baseclass(ar, | ||
443 | 69 | (NaryBaseIterator<ParseURIIterator, PlanIteratorState>*)this); | ||
444 | 70 | } | ||
445 | 71 | |||
446 | 72 | |||
447 | 73 | void ParseURIIterator::accept(PlanIterVisitor& v) const | ||
448 | 74 | { | ||
449 | 75 | v.beginVisit(*this); | ||
450 | 76 | |||
451 | 77 | std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); | ||
452 | 78 | std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); | ||
453 | 79 | for ( ; lIter != lEnd; ++lIter ){ | ||
454 | 80 | (*lIter)->accept(v); | ||
455 | 81 | } | ||
456 | 82 | |||
457 | 83 | v.endVisit(*this); | ||
458 | 84 | } | ||
459 | 85 | |||
460 | 86 | ParseURIIterator::~ParseURIIterator() {} | ||
461 | 87 | |||
462 | 88 | // </ParseURIIterator> | ||
463 | 89 | |||
464 | 90 | |||
465 | 91 | // <SerializeURIIterator> | ||
466 | 92 | SERIALIZABLE_CLASS_VERSIONS(SerializeURIIterator) | ||
467 | 93 | |||
468 | 94 | void SerializeURIIterator::serialize(::zorba::serialization::Archiver& ar) | ||
469 | 95 | { | ||
470 | 96 | serialize_baseclass(ar, | ||
471 | 97 | (NaryBaseIterator<SerializeURIIterator, PlanIteratorState>*)this); | ||
472 | 98 | } | ||
473 | 99 | |||
474 | 100 | |||
475 | 101 | void SerializeURIIterator::accept(PlanIterVisitor& v) const | ||
476 | 102 | { | ||
477 | 103 | v.beginVisit(*this); | ||
478 | 104 | |||
479 | 105 | std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin(); | ||
480 | 106 | std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end(); | ||
481 | 107 | for ( ; lIter != lEnd; ++lIter ){ | ||
482 | 108 | (*lIter)->accept(v); | ||
483 | 109 | } | ||
484 | 110 | |||
485 | 111 | v.endVisit(*this); | ||
486 | 112 | } | ||
487 | 113 | |||
488 | 114 | SerializeURIIterator::~SerializeURIIterator() {} | ||
489 | 115 | |||
490 | 116 | // </SerializeURIIterator> | ||
491 | 117 | |||
492 | 118 | |||
493 | 63 | 119 | ||
494 | 64 | } | 120 | } |
495 | 65 | 121 | ||
496 | 66 | 122 | ||
497 | === modified file 'src/runtime/uris/pregenerated/uris.h' | |||
498 | --- src/runtime/uris/pregenerated/uris.h 2013-03-05 23:11:50 +0000 | |||
499 | +++ src/runtime/uris/pregenerated/uris.h 2013-05-03 23:21:27 +0000 | |||
500 | @@ -67,6 +67,70 @@ | |||
501 | 67 | }; | 67 | }; |
502 | 68 | 68 | ||
503 | 69 | 69 | ||
504 | 70 | /** | ||
505 | 71 | * | ||
506 | 72 | * uri:parse | ||
507 | 73 | * | ||
508 | 74 | * Author: Zorba Team | ||
509 | 75 | */ | ||
510 | 76 | class ParseURIIterator : public NaryBaseIterator<ParseURIIterator, PlanIteratorState> | ||
511 | 77 | { | ||
512 | 78 | public: | ||
513 | 79 | SERIALIZABLE_CLASS(ParseURIIterator); | ||
514 | 80 | |||
515 | 81 | SERIALIZABLE_CLASS_CONSTRUCTOR2T(ParseURIIterator, | ||
516 | 82 | NaryBaseIterator<ParseURIIterator, PlanIteratorState>); | ||
517 | 83 | |||
518 | 84 | void serialize( ::zorba::serialization::Archiver& ar); | ||
519 | 85 | |||
520 | 86 | ParseURIIterator( | ||
521 | 87 | static_context* sctx, | ||
522 | 88 | const QueryLoc& loc, | ||
523 | 89 | std::vector<PlanIter_t>& children) | ||
524 | 90 | : | ||
525 | 91 | NaryBaseIterator<ParseURIIterator, PlanIteratorState>(sctx, loc, children) | ||
526 | 92 | {} | ||
527 | 93 | |||
528 | 94 | virtual ~ParseURIIterator(); | ||
529 | 95 | |||
530 | 96 | void accept(PlanIterVisitor& v) const; | ||
531 | 97 | |||
532 | 98 | bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; | ||
533 | 99 | }; | ||
534 | 100 | |||
535 | 101 | |||
536 | 102 | /** | ||
537 | 103 | * | ||
538 | 104 | * uri:serialize | ||
539 | 105 | * | ||
540 | 106 | * Author: Zorba Team | ||
541 | 107 | */ | ||
542 | 108 | class SerializeURIIterator : public NaryBaseIterator<SerializeURIIterator, PlanIteratorState> | ||
543 | 109 | { | ||
544 | 110 | public: | ||
545 | 111 | SERIALIZABLE_CLASS(SerializeURIIterator); | ||
546 | 112 | |||
547 | 113 | SERIALIZABLE_CLASS_CONSTRUCTOR2T(SerializeURIIterator, | ||
548 | 114 | NaryBaseIterator<SerializeURIIterator, PlanIteratorState>); | ||
549 | 115 | |||
550 | 116 | void serialize( ::zorba::serialization::Archiver& ar); | ||
551 | 117 | |||
552 | 118 | SerializeURIIterator( | ||
553 | 119 | static_context* sctx, | ||
554 | 120 | const QueryLoc& loc, | ||
555 | 121 | std::vector<PlanIter_t>& children) | ||
556 | 122 | : | ||
557 | 123 | NaryBaseIterator<SerializeURIIterator, PlanIteratorState>(sctx, loc, children) | ||
558 | 124 | {} | ||
559 | 125 | |||
560 | 126 | virtual ~SerializeURIIterator(); | ||
561 | 127 | |||
562 | 128 | void accept(PlanIterVisitor& v) const; | ||
563 | 129 | |||
564 | 130 | bool nextImpl(store::Item_t& result, PlanState& aPlanState) const; | ||
565 | 131 | }; | ||
566 | 132 | |||
567 | 133 | |||
568 | 70 | } | 134 | } |
569 | 71 | #endif | 135 | #endif |
570 | 72 | /* | 136 | /* |
571 | 73 | 137 | ||
572 | === modified file 'src/runtime/uris/uris_impl.cpp' | |||
573 | --- src/runtime/uris/uris_impl.cpp 2013-04-16 21:12:12 +0000 | |||
574 | +++ src/runtime/uris/uris_impl.cpp 2013-05-03 23:21:27 +0000 | |||
575 | @@ -32,6 +32,18 @@ | |||
576 | 32 | 32 | ||
577 | 33 | #include "util/uri_util.h" | 33 | #include "util/uri_util.h" |
578 | 34 | 34 | ||
579 | 35 | #include "zorbatypes/URI.h" | ||
580 | 36 | |||
581 | 37 | #define SCHEME_NAME "scheme" | ||
582 | 38 | #define OPAQUE_PART_NAME "opaque-part" | ||
583 | 39 | #define AUTHORITY_NAME "authority" | ||
584 | 40 | #define USER_INFO_NAME "user-info" | ||
585 | 41 | #define HOST_NAME "host" | ||
586 | 42 | #define PORT_NAME "port" | ||
587 | 43 | #define PATH_NAME "path" | ||
588 | 44 | #define QUERY_NAME "query" | ||
589 | 45 | #define FRAGMENT_NAME "fragment" | ||
590 | 46 | |||
591 | 35 | using namespace std; | 47 | using namespace std; |
592 | 36 | 48 | ||
593 | 37 | namespace zorba { | 49 | namespace zorba { |
594 | @@ -101,5 +113,209 @@ | |||
595 | 101 | 113 | ||
596 | 102 | STACK_END (state); | 114 | STACK_END (state); |
597 | 103 | } | 115 | } |
598 | 116 | |||
599 | 117 | /****************************************************************************** | ||
600 | 118 | *******************************************************************************/ | ||
601 | 119 | bool | ||
602 | 120 | ParseURIIterator::nextImpl(store::Item_t& result, PlanState& planState) const | ||
603 | 121 | { | ||
604 | 122 | store::Item_t lItemURI, lName, lValue; | ||
605 | 123 | std::vector<store::Item_t> lNames; | ||
606 | 124 | std::vector<store::Item_t> lValues; | ||
607 | 125 | zorba::zstring lStrURI, lZKey, lZVal; | ||
608 | 126 | PlanIteratorState* state; | ||
609 | 127 | URI uri; | ||
610 | 128 | |||
611 | 129 | DEFAULT_STACK_INIT(PlanIteratorState, state, planState); | ||
612 | 130 | |||
613 | 131 | consumeNext(lItemURI, theChildren[0].getp(), planState); | ||
614 | 132 | lItemURI->getStringValue2(lStrURI); | ||
615 | 133 | uri = URI(lStrURI); | ||
616 | 134 | |||
617 | 135 | lZVal = uri.get_scheme(); | ||
618 | 136 | if(!lZVal.empty()) | ||
619 | 137 | { | ||
620 | 138 | lZKey = zorba::zstring(SCHEME_NAME); | ||
621 | 139 | GENV_ITEMFACTORY->createString(lName, lZKey); | ||
622 | 140 | GENV_ITEMFACTORY->createString(lValue, lZVal); | ||
623 | 141 | lNames.push_back(lName); | ||
624 | 142 | lValues.push_back(lValue); | ||
625 | 143 | } | ||
626 | 144 | |||
627 | 145 | lZVal = uri.get_opaque_part(); | ||
628 | 146 | if(!lZVal.empty()) | ||
629 | 147 | { | ||
630 | 148 | lZKey = zorba::zstring(OPAQUE_PART_NAME); | ||
631 | 149 | GENV_ITEMFACTORY->createString(lName, lZKey); | ||
632 | 150 | GENV_ITEMFACTORY->createString(lValue, lZVal); | ||
633 | 151 | lNames.push_back(lName); | ||
634 | 152 | lValues.push_back(lValue); | ||
635 | 153 | } | ||
636 | 154 | |||
637 | 155 | lZVal = uri.get_encoded_reg_based_authority(); | ||
638 | 156 | if(!lZVal.empty()) | ||
639 | 157 | { | ||
640 | 158 | lZKey = zorba::zstring(AUTHORITY_NAME); | ||
641 | 159 | GENV_ITEMFACTORY->createString(lName, lZKey); | ||
642 | 160 | GENV_ITEMFACTORY->createString(lValue, lZVal); | ||
643 | 161 | lNames.push_back(lName); | ||
644 | 162 | lValues.push_back(lValue); | ||
645 | 163 | } | ||
646 | 164 | |||
647 | 165 | lZVal = uri.get_encoded_user_info(); | ||
648 | 166 | if(!lZVal.empty()) | ||
649 | 167 | { | ||
650 | 168 | lZKey = zorba::zstring(USER_INFO_NAME); | ||
651 | 169 | GENV_ITEMFACTORY->createString(lName, lZKey); | ||
652 | 170 | GENV_ITEMFACTORY->createString(lValue, lZVal); | ||
653 | 171 | lNames.push_back(lName); | ||
654 | 172 | lValues.push_back(lValue); | ||
655 | 173 | } | ||
656 | 174 | |||
657 | 175 | lZVal = uri.get_host(); | ||
658 | 176 | if(!lZVal.empty()) | ||
659 | 177 | { | ||
660 | 178 | lZKey = zorba::zstring(HOST_NAME); | ||
661 | 179 | GENV_ITEMFACTORY->createString(lName, lZKey); | ||
662 | 180 | GENV_ITEMFACTORY->createString(lValue, lZVal); | ||
663 | 181 | lNames.push_back(lName); | ||
664 | 182 | lValues.push_back(lValue); | ||
665 | 183 | } | ||
666 | 184 | |||
667 | 185 | if(uri.get_port() != 0) | ||
668 | 186 | { | ||
669 | 187 | lZKey = zorba::zstring(PORT_NAME); | ||
670 | 188 | GENV_ITEMFACTORY->createString(lName, lZKey); | ||
671 | 189 | GENV_ITEMFACTORY->createInt(lValue, uri.get_port()); | ||
672 | 190 | lNames.push_back(lName); | ||
673 | 191 | lValues.push_back(lValue); | ||
674 | 192 | } | ||
675 | 193 | |||
676 | 194 | lZVal = uri.get_encoded_path(); | ||
677 | 195 | if(!lZVal.empty()) | ||
678 | 196 | { | ||
679 | 197 | lZKey = zorba::zstring(PATH_NAME); | ||
680 | 198 | GENV_ITEMFACTORY->createString(lName, lZKey); | ||
681 | 199 | GENV_ITEMFACTORY->createString(lValue, lZVal); | ||
682 | 200 | lNames.push_back(lName); | ||
683 | 201 | lValues.push_back(lValue); | ||
684 | 202 | } | ||
685 | 203 | |||
686 | 204 | lZVal = uri.get_encoded_query(); | ||
687 | 205 | if(uri.is_set(URI::QueryString)) | ||
688 | 206 | { | ||
689 | 207 | lZKey = zorba::zstring(QUERY_NAME); | ||
690 | 208 | GENV_ITEMFACTORY->createString(lName, lZKey); | ||
691 | 209 | GENV_ITEMFACTORY->createString(lValue, lZVal); | ||
692 | 210 | lNames.push_back(lName); | ||
693 | 211 | lValues.push_back(lValue); | ||
694 | 212 | } | ||
695 | 213 | |||
696 | 214 | lZVal = uri.get_encoded_fragment(); | ||
697 | 215 | if(!lZVal.empty()) | ||
698 | 216 | { | ||
699 | 217 | lZKey = zorba::zstring(FRAGMENT_NAME); | ||
700 | 218 | GENV_ITEMFACTORY->createString(lName, lZKey); | ||
701 | 219 | GENV_ITEMFACTORY->createString(lValue, lZVal); | ||
702 | 220 | lNames.push_back(lName); | ||
703 | 221 | lValues.push_back(lValue); | ||
704 | 222 | } | ||
705 | 223 | |||
706 | 224 | GENV_ITEMFACTORY->createJSONObject(result, lNames, lValues); | ||
707 | 225 | |||
708 | 226 | STACK_PUSH(result, state ); | ||
709 | 227 | |||
710 | 228 | STACK_END (state); | ||
711 | 229 | } | ||
712 | 230 | |||
713 | 231 | /****************************************************************************** | ||
714 | 232 | *******************************************************************************/ | ||
715 | 233 | bool | ||
716 | 234 | SerializeURIIterator::nextImpl(store::Item_t& result, PlanState& planState) const | ||
717 | 235 | { | ||
718 | 236 | store::Item_t lItemURI, lItemKey; | ||
719 | 237 | zorba::zstring lStrValue, lStrKey, lStrRes; | ||
720 | 238 | store::Iterator_t lKeys; | ||
721 | 239 | URI uri = URI(); | ||
722 | 240 | int lIntPort = 0; | ||
723 | 241 | bool lHasSchemeField, lHasOpaqueField, lHasNotOpaqueField; | ||
724 | 242 | |||
725 | 243 | PlanIteratorState* state; | ||
726 | 244 | DEFAULT_STACK_INIT(PlanIteratorState, state, planState); | ||
727 | 245 | |||
728 | 246 | consumeNext(lItemURI, theChildren[0].getp(), planState); | ||
729 | 247 | |||
730 | 248 | lHasSchemeField = lHasOpaqueField = lHasNotOpaqueField = false; | ||
731 | 249 | if(lItemURI->isJSONObject()) { | ||
732 | 250 | lKeys = lItemURI->getObjectKeys(); | ||
733 | 251 | if(!lKeys.isNull()){ | ||
734 | 252 | lKeys->open(); | ||
735 | 253 | while(lKeys->next(lItemKey)){ | ||
736 | 254 | lStrKey = lItemKey->getStringValue(); | ||
737 | 255 | lStrValue = lItemURI->getObjectValue(lItemKey)->getStringValue(); | ||
738 | 256 | if(lStrKey == SCHEME_NAME && !lStrValue.empty()){ | ||
739 | 257 | uri.set_scheme(lStrValue); | ||
740 | 258 | lHasSchemeField = true; | ||
741 | 259 | } else if(lStrKey == OPAQUE_PART_NAME && !lStrValue.empty()){ | ||
742 | 260 | uri.set_opaque_part(lStrValue); | ||
743 | 261 | lHasOpaqueField = true; | ||
744 | 262 | } else if(lStrKey == AUTHORITY_NAME && !lStrValue.empty()){ | ||
745 | 263 | uri.set_reg_based_authority(lStrValue); | ||
746 | 264 | lHasNotOpaqueField = true; | ||
747 | 265 | } else if(lStrKey == USER_INFO_NAME && !lStrValue.empty()){ | ||
748 | 266 | uri.set_user_info(lStrValue); | ||
749 | 267 | lHasNotOpaqueField = true; | ||
750 | 268 | } else if(lStrKey == HOST_NAME && !lStrValue.empty()){ | ||
751 | 269 | uri.set_host(lStrValue); | ||
752 | 270 | lHasNotOpaqueField = true; | ||
753 | 271 | } else if(lStrKey == PORT_NAME){ | ||
754 | 272 | sscanf(lStrValue.str().c_str(), "%d", &lIntPort); | ||
755 | 273 | if(lIntPort != 0){ | ||
756 | 274 | uri.set_port(lIntPort); | ||
757 | 275 | lHasNotOpaqueField = true; | ||
758 | 276 | } | ||
759 | 277 | } else if(lStrKey == PATH_NAME && !lStrValue.empty()){ | ||
760 | 278 | uri.set_path(lStrValue); | ||
761 | 279 | lHasNotOpaqueField = true; | ||
762 | 280 | } else if(lStrKey == QUERY_NAME){ | ||
763 | 281 | uri.set_query(lStrValue); | ||
764 | 282 | lHasNotOpaqueField = true; | ||
765 | 283 | } else if(lStrKey == FRAGMENT_NAME){ | ||
766 | 284 | uri.set_fragment(lStrValue); | ||
767 | 285 | } | ||
768 | 286 | } | ||
769 | 287 | lKeys->close(); | ||
770 | 288 | } | ||
771 | 289 | } | ||
772 | 290 | |||
773 | 291 | // check for errors | ||
774 | 292 | if(lHasOpaqueField && lHasNotOpaqueField) | ||
775 | 293 | { | ||
776 | 294 | throw XQUERY_EXCEPTION( | ||
777 | 295 | zerr::ZURI0001_OPAQUE_WITH_OTHERS, | ||
778 | 296 | ERROR_LOC( loc ) | ||
779 | 297 | ); | ||
780 | 298 | } | ||
781 | 299 | if(lHasOpaqueField && !lHasSchemeField) | ||
782 | 300 | { | ||
783 | 301 | throw XQUERY_EXCEPTION( | ||
784 | 302 | zerr::ZURI0002_SCHEME_REQUIRED_FOR_OPAQUE, | ||
785 | 303 | ERROR_LOC( loc ) | ||
786 | 304 | ); | ||
787 | 305 | } | ||
788 | 306 | if(lHasSchemeField && !uri.get_encoded_path().empty() && (uri.get_encoded_path().substr(0,1) != "/")) | ||
789 | 307 | { | ||
790 | 308 | throw XQUERY_EXCEPTION( | ||
791 | 309 | zerr::ZURI0003_SLASH_NEEDED_FOR_ABSOLUTE_URI, | ||
792 | 310 | ERROR_LOC( loc ) | ||
793 | 311 | ); | ||
794 | 312 | } | ||
795 | 313 | |||
796 | 314 | lStrRes = zorba::zstring(uri.toString()); | ||
797 | 315 | STACK_PUSH(GENV_ITEMFACTORY->createString(result, lStrRes), state ); | ||
798 | 316 | |||
799 | 317 | STACK_END (state); | ||
800 | 318 | } | ||
801 | 319 | |||
802 | 104 | } // namespace zorba | 320 | } // namespace zorba |
803 | 105 | /* vim:set et sw=2 ts=2: */ | 321 | /* vim:set et sw=2 ts=2: */ |
804 | 106 | 322 | ||
805 | === modified file 'src/runtime/visitors/pregenerated/planiter_visitor.h' | |||
806 | --- src/runtime/visitors/pregenerated/planiter_visitor.h 2013-03-15 08:22:41 +0000 | |||
807 | +++ src/runtime/visitors/pregenerated/planiter_visitor.h 2013-05-03 23:21:27 +0000 | |||
808 | @@ -766,6 +766,10 @@ | |||
809 | 766 | 766 | ||
810 | 767 | class DecodeURIIterator; | 767 | class DecodeURIIterator; |
811 | 768 | 768 | ||
812 | 769 | class ParseURIIterator; | ||
813 | 770 | |||
814 | 771 | class SerializeURIIterator; | ||
815 | 772 | |||
816 | 769 | class XQDocContentIterator; | 773 | class XQDocContentIterator; |
817 | 770 | 774 | ||
818 | 771 | 775 | ||
819 | @@ -1863,6 +1867,12 @@ | |||
820 | 1863 | virtual void beginVisit ( const DecodeURIIterator& ) = 0; | 1867 | virtual void beginVisit ( const DecodeURIIterator& ) = 0; |
821 | 1864 | virtual void endVisit ( const DecodeURIIterator& ) = 0; | 1868 | virtual void endVisit ( const DecodeURIIterator& ) = 0; |
822 | 1865 | 1869 | ||
823 | 1870 | virtual void beginVisit ( const ParseURIIterator& ) = 0; | ||
824 | 1871 | virtual void endVisit ( const ParseURIIterator& ) = 0; | ||
825 | 1872 | |||
826 | 1873 | virtual void beginVisit ( const SerializeURIIterator& ) = 0; | ||
827 | 1874 | virtual void endVisit ( const SerializeURIIterator& ) = 0; | ||
828 | 1875 | |||
829 | 1866 | virtual void beginVisit ( const XQDocContentIterator& ) = 0; | 1876 | virtual void beginVisit ( const XQDocContentIterator& ) = 0; |
830 | 1867 | virtual void endVisit ( const XQDocContentIterator& ) = 0; | 1877 | virtual void endVisit ( const XQDocContentIterator& ) = 0; |
831 | 1868 | 1878 | ||
832 | 1869 | 1879 | ||
833 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.cpp' | |||
834 | --- src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-03-27 00:44:34 +0000 | |||
835 | +++ src/runtime/visitors/pregenerated/printer_visitor.cpp 2013-05-03 23:21:27 +0000 | |||
836 | @@ -4905,6 +4905,34 @@ | |||
837 | 4905 | // </DecodeURIIterator> | 4905 | // </DecodeURIIterator> |
838 | 4906 | 4906 | ||
839 | 4907 | 4907 | ||
840 | 4908 | // <ParseURIIterator> | ||
841 | 4909 | void PrinterVisitor::beginVisit ( const ParseURIIterator& a) { | ||
842 | 4910 | thePrinter.startBeginVisit("ParseURIIterator", ++theId); | ||
843 | 4911 | printCommons( &a, theId ); | ||
844 | 4912 | thePrinter.endBeginVisit( theId ); | ||
845 | 4913 | } | ||
846 | 4914 | |||
847 | 4915 | void PrinterVisitor::endVisit ( const ParseURIIterator& ) { | ||
848 | 4916 | thePrinter.startEndVisit(); | ||
849 | 4917 | thePrinter.endEndVisit(); | ||
850 | 4918 | } | ||
851 | 4919 | // </ParseURIIterator> | ||
852 | 4920 | |||
853 | 4921 | |||
854 | 4922 | // <SerializeURIIterator> | ||
855 | 4923 | void PrinterVisitor::beginVisit ( const SerializeURIIterator& a) { | ||
856 | 4924 | thePrinter.startBeginVisit("SerializeURIIterator", ++theId); | ||
857 | 4925 | printCommons( &a, theId ); | ||
858 | 4926 | thePrinter.endBeginVisit( theId ); | ||
859 | 4927 | } | ||
860 | 4928 | |||
861 | 4929 | void PrinterVisitor::endVisit ( const SerializeURIIterator& ) { | ||
862 | 4930 | thePrinter.startEndVisit(); | ||
863 | 4931 | thePrinter.endEndVisit(); | ||
864 | 4932 | } | ||
865 | 4933 | // </SerializeURIIterator> | ||
866 | 4934 | |||
867 | 4935 | |||
868 | 4908 | // <XQDocContentIterator> | 4936 | // <XQDocContentIterator> |
869 | 4909 | void PrinterVisitor::beginVisit ( const XQDocContentIterator& a) { | 4937 | void PrinterVisitor::beginVisit ( const XQDocContentIterator& a) { |
870 | 4910 | thePrinter.startBeginVisit("XQDocContentIterator", ++theId); | 4938 | thePrinter.startBeginVisit("XQDocContentIterator", ++theId); |
871 | 4911 | 4939 | ||
872 | === modified file 'src/runtime/visitors/pregenerated/printer_visitor.h' | |||
873 | --- src/runtime/visitors/pregenerated/printer_visitor.h 2013-03-15 08:22:41 +0000 | |||
874 | +++ src/runtime/visitors/pregenerated/printer_visitor.h 2013-05-03 23:21:27 +0000 | |||
875 | @@ -1170,6 +1170,12 @@ | |||
876 | 1170 | void beginVisit( const DecodeURIIterator& ); | 1170 | void beginVisit( const DecodeURIIterator& ); |
877 | 1171 | void endVisit ( const DecodeURIIterator& ); | 1171 | void endVisit ( const DecodeURIIterator& ); |
878 | 1172 | 1172 | ||
879 | 1173 | void beginVisit( const ParseURIIterator& ); | ||
880 | 1174 | void endVisit ( const ParseURIIterator& ); | ||
881 | 1175 | |||
882 | 1176 | void beginVisit( const SerializeURIIterator& ); | ||
883 | 1177 | void endVisit ( const SerializeURIIterator& ); | ||
884 | 1178 | |||
885 | 1173 | void beginVisit( const XQDocContentIterator& ); | 1179 | void beginVisit( const XQDocContentIterator& ); |
886 | 1174 | void endVisit ( const XQDocContentIterator& ); | 1180 | void endVisit ( const XQDocContentIterator& ); |
887 | 1175 | 1181 | ||
888 | 1176 | 1182 | ||
889 | === modified file 'src/unit_tests/test_uri.cpp' | |||
890 | --- src/unit_tests/test_uri.cpp 2013-02-07 17:24:36 +0000 | |||
891 | +++ src/unit_tests/test_uri.cpp 2013-05-03 23:21:27 +0000 | |||
892 | @@ -40,6 +40,7 @@ | |||
893 | 40 | zorba::zstring userinfo; | 40 | zorba::zstring userinfo; |
894 | 41 | zorba::zstring query; | 41 | zorba::zstring query; |
895 | 42 | zorba::zstring path_notation; | 42 | zorba::zstring path_notation; |
896 | 43 | zorba::zstring opaque_part; | ||
897 | 43 | }; | 44 | }; |
898 | 44 | 45 | ||
899 | 45 | 46 | ||
900 | @@ -66,7 +67,8 @@ | |||
901 | 66 | "/", | 67 | "/", |
902 | 67 | "", | 68 | "", |
903 | 68 | "", | 69 | "", |
905 | 69 | "/" // path notation | 70 | "/", // path notation |
906 | 71 | "" | ||
907 | 70 | }, | 72 | }, |
908 | 71 | { | 73 | { |
909 | 72 | "", | 74 | "", |
910 | @@ -80,7 +82,8 @@ | |||
911 | 80 | "/", | 82 | "/", |
912 | 81 | "", | 83 | "", |
913 | 82 | "", | 84 | "", |
915 | 83 | "com/zorba-xquery/www/" // path notation | 85 | "com/zorba-xquery/www/", // path notation |
916 | 86 | "" | ||
917 | 84 | }, | 87 | }, |
918 | 85 | { | 88 | { |
919 | 86 | "", | 89 | "", |
920 | @@ -94,7 +97,8 @@ | |||
921 | 94 | "/", | 97 | "/", |
922 | 95 | "", | 98 | "", |
923 | 96 | "abc=true", | 99 | "abc=true", |
925 | 97 | "com/zorba-xquery/www/" // path notation | 100 | "com/zorba-xquery/www/", // path notation |
926 | 101 | "" | ||
927 | 98 | }, | 102 | }, |
928 | 99 | { | 103 | { |
929 | 100 | "", | 104 | "", |
930 | @@ -108,7 +112,8 @@ | |||
931 | 108 | "/", | 112 | "/", |
932 | 109 | "", | 113 | "", |
933 | 110 | "abc=true", | 114 | "abc=true", |
935 | 111 | "com/zorba-xquery/www/" // path notation | 115 | "com/zorba-xquery/www/", // path notation |
936 | 116 | "" | ||
937 | 112 | }, | 117 | }, |
938 | 113 | { | 118 | { |
939 | 114 | "", | 119 | "", |
940 | @@ -122,7 +127,8 @@ | |||
941 | 122 | "/", | 127 | "/", |
942 | 123 | "user", | 128 | "user", |
943 | 124 | "abc=true", | 129 | "abc=true", |
945 | 125 | "com/zorba-xquery/www/" // path notation | 130 | "com/zorba-xquery/www/", // path notation |
946 | 131 | "" | ||
947 | 126 | }, | 132 | }, |
948 | 127 | { | 133 | { |
949 | 128 | "", | 134 | "", |
950 | @@ -136,7 +142,8 @@ | |||
951 | 136 | "/path1/path2", | 142 | "/path1/path2", |
952 | 137 | "user", | 143 | "user", |
953 | 138 | "abc=true", | 144 | "abc=true", |
955 | 139 | "com/zorba-xquery/www/path1/path2" // path notation | 145 | "com/zorba-xquery/www/path1/path2", // path notation |
956 | 146 | "" | ||
957 | 140 | }, | 147 | }, |
958 | 141 | { | 148 | { |
959 | 142 | "", | 149 | "", |
960 | @@ -150,7 +157,8 @@ | |||
961 | 150 | "/path1/path2", | 157 | "/path1/path2", |
962 | 151 | "user", | 158 | "user", |
963 | 152 | "abc=true&bcd=false", | 159 | "abc=true&bcd=false", |
965 | 153 | "com/zorba-xquery/www/path1/path2" // path notation | 160 | "com/zorba-xquery/www/path1/path2", // path notation |
966 | 161 | "" | ||
967 | 154 | }, | 162 | }, |
968 | 155 | { | 163 | { |
969 | 156 | "", | 164 | "", |
970 | @@ -164,7 +172,8 @@ | |||
971 | 164 | "/rfc/rfc1808.txt", | 172 | "/rfc/rfc1808.txt", |
972 | 165 | "", | 173 | "", |
973 | 166 | "", | 174 | "", |
975 | 167 | "za/co/is/ftp/rfc/rfc1808.txt" // path notation | 175 | "za/co/is/ftp/rfc/rfc1808.txt", // path notation |
976 | 176 | "" | ||
977 | 168 | }, | 177 | }, |
978 | 169 | { | 178 | { |
979 | 170 | "", | 179 | "", |
980 | @@ -178,7 +187,8 @@ | |||
981 | 178 | "/test", | 187 | "/test", |
982 | 179 | "thomas", | 188 | "thomas", |
983 | 180 | "", | 189 | "", |
985 | 181 | "[2001:6f8:9000:876:cccc:bbbb::]/test" // path notation | 190 | "[2001:6f8:9000:876:cccc:bbbb::]/test", // path notation |
986 | 191 | "" | ||
987 | 182 | }, | 192 | }, |
988 | 183 | // uri resolver tests | 193 | // uri resolver tests |
989 | 184 | { | 194 | { |
990 | @@ -193,7 +203,8 @@ | |||
991 | 193 | "/b/c/g", | 203 | "/b/c/g", |
992 | 194 | "", | 204 | "", |
993 | 195 | "", | 205 | "", |
995 | 196 | "a/b/c/g" // path notation | 206 | "a/b/c/g", // path notation |
996 | 207 | "" | ||
997 | 197 | }, | 208 | }, |
998 | 198 | { | 209 | { |
999 | 199 | "http://a/b/c/d;p?q", | 210 | "http://a/b/c/d;p?q", |
1000 | @@ -207,7 +218,8 @@ | |||
1001 | 207 | "/b/c/g", | 218 | "/b/c/g", |
1002 | 208 | "", | 219 | "", |
1003 | 209 | "", | 220 | "", |
1005 | 210 | "a/b/c/g" // path notation | 221 | "a/b/c/g", // path notation |
1006 | 222 | "" | ||
1007 | 211 | }, | 223 | }, |
1008 | 212 | { | 224 | { |
1009 | 213 | "http://a/b/c/d;p?q", | 225 | "http://a/b/c/d;p?q", |
1010 | @@ -221,7 +233,8 @@ | |||
1011 | 221 | "/b/c/g/", | 233 | "/b/c/g/", |
1012 | 222 | "", | 234 | "", |
1013 | 223 | "", | 235 | "", |
1015 | 224 | "a/b/c/g/" // path notation | 236 | "a/b/c/g/", // path notation |
1016 | 237 | "" | ||
1017 | 225 | }, | 238 | }, |
1018 | 226 | { | 239 | { |
1019 | 227 | "http://a/b/c/d;p?q", | 240 | "http://a/b/c/d;p?q", |
1020 | @@ -235,7 +248,8 @@ | |||
1021 | 235 | "/g", | 248 | "/g", |
1022 | 236 | "", | 249 | "", |
1023 | 237 | "", | 250 | "", |
1025 | 238 | "a/g" // path notation | 251 | "a/g", // path notation |
1026 | 252 | "" | ||
1027 | 239 | }, | 253 | }, |
1028 | 240 | { | 254 | { |
1029 | 241 | "http://a/b/c/d;p?q", | 255 | "http://a/b/c/d;p?q", |
1030 | @@ -249,7 +263,8 @@ | |||
1031 | 249 | "/b/c/", | 263 | "/b/c/", |
1032 | 250 | "", | 264 | "", |
1033 | 251 | "y", | 265 | "y", |
1035 | 252 | "a/b/c/" // path notation | 266 | "a/b/c/", // path notation |
1036 | 267 | "" | ||
1037 | 253 | }, | 268 | }, |
1038 | 254 | { | 269 | { |
1039 | 255 | "http://a/b/c/d;p?q", | 270 | "http://a/b/c/d;p?q", |
1040 | @@ -263,7 +278,8 @@ | |||
1041 | 263 | "/b/c/g", | 278 | "/b/c/g", |
1042 | 264 | "", | 279 | "", |
1043 | 265 | "y", | 280 | "y", |
1045 | 266 | "a/b/c/g" // path notation | 281 | "a/b/c/g", // path notation |
1046 | 282 | "" | ||
1047 | 267 | } //, | 283 | } //, |
1048 | 268 | //{ | 284 | //{ |
1049 | 269 | // "http://a/b/c/d;p?q", | 285 | // "http://a/b/c/d;p?q", |
1050 | @@ -276,6 +292,7 @@ | |||
1051 | 276 | // "", | 292 | // "", |
1052 | 277 | // "/b/c/g", | 293 | // "/b/c/g", |
1053 | 278 | // "", | 294 | // "", |
1054 | 295 | // "". | ||
1055 | 279 | // "" | 296 | // "" |
1056 | 280 | //} | 297 | //} |
1057 | 281 | , | 298 | , |
1058 | @@ -291,7 +308,8 @@ | |||
1059 | 291 | "/b/c/g", | 308 | "/b/c/g", |
1060 | 292 | "", | 309 | "", |
1061 | 293 | "", | 310 | "", |
1063 | 294 | "a/b/c/g" // path notation | 311 | "a/b/c/g", // path notation |
1064 | 312 | "" | ||
1065 | 295 | }, | 313 | }, |
1066 | 296 | { | 314 | { |
1067 | 297 | "http://a/b/c/d;p?q", | 315 | "http://a/b/c/d;p?q", |
1068 | @@ -305,7 +323,8 @@ | |||
1069 | 305 | "/b/c/g", | 323 | "/b/c/g", |
1070 | 306 | "", | 324 | "", |
1071 | 307 | "y", | 325 | "y", |
1073 | 308 | "a/b/c/g" // path notation | 326 | "a/b/c/g", // path notation |
1074 | 327 | "" | ||
1075 | 309 | }, | 328 | }, |
1076 | 310 | { | 329 | { |
1077 | 311 | "http://a/b/c/d;p?q", | 330 | "http://a/b/c/d;p?q", |
1078 | @@ -319,7 +338,8 @@ | |||
1079 | 319 | "/b/c/;x", | 338 | "/b/c/;x", |
1080 | 320 | "", | 339 | "", |
1081 | 321 | "", | 340 | "", |
1083 | 322 | "a/b/c/;x" // path notation | 341 | "a/b/c/;x", // path notation |
1084 | 342 | "" | ||
1085 | 323 | }, | 343 | }, |
1086 | 324 | { | 344 | { |
1087 | 325 | "http://a/b/c/d;p?q", | 345 | "http://a/b/c/d;p?q", |
1088 | @@ -333,7 +353,8 @@ | |||
1089 | 333 | "/b/c/g;x", | 353 | "/b/c/g;x", |
1090 | 334 | "", | 354 | "", |
1091 | 335 | "", | 355 | "", |
1093 | 336 | "a/b/c/g;x" // path notation | 356 | "a/b/c/g;x", // path notation |
1094 | 357 | "" | ||
1095 | 337 | }, | 358 | }, |
1096 | 338 | { | 359 | { |
1097 | 339 | "http://a/b/c/d;p?q", | 360 | "http://a/b/c/d;p?q", |
1098 | @@ -347,7 +368,8 @@ | |||
1099 | 347 | "/b/c/g;x", | 368 | "/b/c/g;x", |
1100 | 348 | "", | 369 | "", |
1101 | 349 | "y", | 370 | "y", |
1103 | 350 | "a/b/c/g;x" // path notation | 371 | "a/b/c/g;x", // path notation |
1104 | 372 | "" | ||
1105 | 351 | }, | 373 | }, |
1106 | 352 | { | 374 | { |
1107 | 353 | "http://a/b/c/d;p?q", | 375 | "http://a/b/c/d;p?q", |
1108 | @@ -361,7 +383,8 @@ | |||
1109 | 361 | "/b/c/", | 383 | "/b/c/", |
1110 | 362 | "", | 384 | "", |
1111 | 363 | "", | 385 | "", |
1113 | 364 | "a/b/c/" // path notation | 386 | "a/b/c/", // path notation |
1114 | 387 | "" | ||
1115 | 365 | }, | 388 | }, |
1116 | 366 | { | 389 | { |
1117 | 367 | "http://a/b/c/d;p?q", | 390 | "http://a/b/c/d;p?q", |
1118 | @@ -375,7 +398,8 @@ | |||
1119 | 375 | "/b/c/", | 398 | "/b/c/", |
1120 | 376 | "", | 399 | "", |
1121 | 377 | "", | 400 | "", |
1123 | 378 | "a/b/c/" // path notation | 401 | "a/b/c/", // path notation |
1124 | 402 | "" | ||
1125 | 379 | }, | 403 | }, |
1126 | 380 | { | 404 | { |
1127 | 381 | "http://a/b/c/d;p?q", | 405 | "http://a/b/c/d;p?q", |
1128 | @@ -389,7 +413,8 @@ | |||
1129 | 389 | "/b/", | 413 | "/b/", |
1130 | 390 | "", | 414 | "", |
1131 | 391 | "", | 415 | "", |
1133 | 392 | "a/b/" // path notation | 416 | "a/b/", // path notation |
1134 | 417 | "" | ||
1135 | 393 | }, | 418 | }, |
1136 | 394 | { | 419 | { |
1137 | 395 | "http://a/b/c/d;p?q", | 420 | "http://a/b/c/d;p?q", |
1138 | @@ -403,7 +428,8 @@ | |||
1139 | 403 | "/b/", | 428 | "/b/", |
1140 | 404 | "", | 429 | "", |
1141 | 405 | "", | 430 | "", |
1143 | 406 | "a/b/" // path notation | 431 | "a/b/", // path notation |
1144 | 432 | "" | ||
1145 | 407 | }, | 433 | }, |
1146 | 408 | { | 434 | { |
1147 | 409 | "http://a/b/c/d;p?q", | 435 | "http://a/b/c/d;p?q", |
1148 | @@ -417,7 +443,8 @@ | |||
1149 | 417 | "/b/g", | 443 | "/b/g", |
1150 | 418 | "", | 444 | "", |
1151 | 419 | "", | 445 | "", |
1153 | 420 | "a/b/g" // path notation | 446 | "a/b/g", // path notation |
1154 | 447 | "" | ||
1155 | 421 | }, | 448 | }, |
1156 | 422 | { | 449 | { |
1157 | 423 | "http://a/b/c/d;p?q", | 450 | "http://a/b/c/d;p?q", |
1158 | @@ -431,7 +458,8 @@ | |||
1159 | 431 | "/", | 458 | "/", |
1160 | 432 | "", | 459 | "", |
1161 | 433 | "", | 460 | "", |
1163 | 434 | "a/" // path notation | 461 | "a/", // path notation |
1164 | 462 | "" | ||
1165 | 435 | }, | 463 | }, |
1166 | 436 | { | 464 | { |
1167 | 437 | "http://a/b/c/d;p?q", | 465 | "http://a/b/c/d;p?q", |
1168 | @@ -445,7 +473,8 @@ | |||
1169 | 445 | "/", | 473 | "/", |
1170 | 446 | "", | 474 | "", |
1171 | 447 | "", | 475 | "", |
1173 | 448 | "a/" // path notation | 476 | "a/", // path notation |
1174 | 477 | "" | ||
1175 | 449 | }, | 478 | }, |
1176 | 450 | { | 479 | { |
1177 | 451 | "http://a/b/c/d;p?q", | 480 | "http://a/b/c/d;p?q", |
1178 | @@ -459,7 +488,8 @@ | |||
1179 | 459 | "/g", | 488 | "/g", |
1180 | 460 | "", | 489 | "", |
1181 | 461 | "", | 490 | "", |
1183 | 462 | "a/g" // path notation | 491 | "a/g", // path notation |
1184 | 492 | "" | ||
1185 | 463 | }, | 493 | }, |
1186 | 464 | { | 494 | { |
1187 | 465 | "http://a/b/c/d;p?q", | 495 | "http://a/b/c/d;p?q", |
1188 | @@ -473,7 +503,8 @@ | |||
1189 | 473 | "/b/c/g;x=1/y", | 503 | "/b/c/g;x=1/y", |
1190 | 474 | "", | 504 | "", |
1191 | 475 | "", | 505 | "", |
1193 | 476 | "a/b/c/g;x=1/y" // path notation | 506 | "a/b/c/g;x=1/y", // path notation |
1194 | 507 | "" | ||
1195 | 477 | }, | 508 | }, |
1196 | 478 | { | 509 | { |
1197 | 479 | "http://a/b/c/d;p?q", | 510 | "http://a/b/c/d;p?q", |
1198 | @@ -487,7 +518,8 @@ | |||
1199 | 487 | "/b/c/y", | 518 | "/b/c/y", |
1200 | 488 | "", | 519 | "", |
1201 | 489 | "", | 520 | "", |
1203 | 490 | "a/b/c/y" // path notation | 521 | "a/b/c/y", // path notation |
1204 | 522 | "" | ||
1205 | 491 | }, | 523 | }, |
1206 | 492 | { | 524 | { |
1207 | 493 | "http://a/b/c/d;p?q", | 525 | "http://a/b/c/d;p?q", |
1208 | @@ -501,7 +533,8 @@ | |||
1209 | 501 | "/b/c/g", | 533 | "/b/c/g", |
1210 | 502 | "", | 534 | "", |
1211 | 503 | "", | 535 | "", |
1213 | 504 | "a/b/c/g" // path notation | 536 | "a/b/c/g", // path notation |
1214 | 537 | "" | ||
1215 | 505 | }, | 538 | }, |
1216 | 506 | { | 539 | { |
1217 | 507 | "http://www.example.com/", | 540 | "http://www.example.com/", |
1218 | @@ -515,7 +548,8 @@ | |||
1219 | 515 | "/", | 548 | "/", |
1220 | 516 | "", | 549 | "", |
1221 | 517 | "", | 550 | "", |
1223 | 518 | "example.com" // path notation | 551 | "example.com", // path notation |
1224 | 552 | "" | ||
1225 | 519 | }, | 553 | }, |
1226 | 520 | { | 554 | { |
1227 | 521 | "http://www.example.com/", | 555 | "http://www.example.com/", |
1228 | @@ -529,7 +563,8 @@ | |||
1229 | 529 | "/dir/file", | 563 | "/dir/file", |
1230 | 530 | "", | 564 | "", |
1231 | 531 | "", | 565 | "", |
1233 | 532 | "example.com" // path notation | 566 | "example.com", // path notation |
1234 | 567 | "" | ||
1235 | 533 | }, | 568 | }, |
1236 | 534 | { | 569 | { |
1237 | 535 | "", | 570 | "", |
1238 | @@ -543,7 +578,8 @@ | |||
1239 | 543 | "", | 578 | "", |
1240 | 544 | "", | 579 | "", |
1241 | 545 | "", | 580 | "", |
1243 | 546 | "de/msb/www" // path notation | 581 | "de/msb/www", // path notation |
1244 | 582 | "" | ||
1245 | 547 | }, | 583 | }, |
1246 | 548 | { | 584 | { |
1247 | 549 | "http://www.msb.de/", | 585 | "http://www.msb.de/", |
1248 | @@ -557,7 +593,8 @@ | |||
1249 | 557 | "/lib/helpers", | 593 | "/lib/helpers", |
1250 | 558 | "", | 594 | "", |
1251 | 559 | "", | 595 | "", |
1253 | 560 | "de/msb/www/lib/helpers" // path notation | 596 | "de/msb/www/lib/helpers", // path notation |
1254 | 597 | "" | ||
1255 | 561 | }, | 598 | }, |
1256 | 562 | { | 599 | { |
1257 | 563 | "", | 600 | "", |
1258 | @@ -575,7 +612,8 @@ | |||
1259 | 575 | #endif | 612 | #endif |
1260 | 576 | "", | 613 | "", |
1261 | 577 | "", | 614 | "", |
1263 | 578 | "/d:/a/b/c" // path notation | 615 | "/d:/a/b/c", // path notation |
1264 | 616 | "" | ||
1265 | 579 | }, | 617 | }, |
1266 | 580 | { | 618 | { |
1267 | 581 | "", | 619 | "", |
1268 | @@ -593,7 +631,8 @@ | |||
1269 | 593 | #endif | 631 | #endif |
1270 | 594 | "", | 632 | "", |
1271 | 595 | "", | 633 | "", |
1273 | 596 | "localhost/d:/a/b/c" // path notation | 634 | "localhost/d:/a/b/c", // path notation |
1274 | 635 | "" | ||
1275 | 597 | }, | 636 | }, |
1276 | 598 | { | 637 | { |
1277 | 599 | "file://localhost", | 638 | "file://localhost", |
1278 | @@ -607,7 +646,83 @@ | |||
1279 | 607 | "/Ångström/b/c", | 646 | "/Ångström/b/c", |
1280 | 608 | "", | 647 | "", |
1281 | 609 | "", | 648 | "", |
1283 | 610 | "localhost/Ångström/b/c" // path notation | 649 | "localhost/Ångström/b/c", // path notation |
1284 | 650 | "" | ||
1285 | 651 | }, | ||
1286 | 652 | { | ||
1287 | 653 | "", | ||
1288 | 654 | "opaq:opaque-uri-part#frag", | ||
1289 | 655 | "opaq:opaque-uri-part#frag", | ||
1290 | 656 | "opaq", | ||
1291 | 657 | 0, | ||
1292 | 658 | "frag", | ||
1293 | 659 | "", | ||
1294 | 660 | "", | ||
1295 | 661 | "", | ||
1296 | 662 | "", | ||
1297 | 663 | "", | ||
1298 | 664 | "opaque-uri-part", | ||
1299 | 665 | "opaque-uri-part" | ||
1300 | 666 | }, | ||
1301 | 667 | { | ||
1302 | 668 | "opaq:opaque-uri-part", | ||
1303 | 669 | "#frag", | ||
1304 | 670 | "opaq:opaque-uri-part#frag", | ||
1305 | 671 | "opaq", | ||
1306 | 672 | 0, | ||
1307 | 673 | "frag", | ||
1308 | 674 | "", | ||
1309 | 675 | "", | ||
1310 | 676 | "", | ||
1311 | 677 | "", | ||
1312 | 678 | "", | ||
1313 | 679 | "opaque-uri-part", | ||
1314 | 680 | "opaque-uri-part" | ||
1315 | 681 | }, | ||
1316 | 682 | { | ||
1317 | 683 | "", | ||
1318 | 684 | "opaq:text-file.txt", | ||
1319 | 685 | "opaq:text-file.txt", | ||
1320 | 686 | "opaq", | ||
1321 | 687 | 0, | ||
1322 | 688 | "", | ||
1323 | 689 | "", | ||
1324 | 690 | "", | ||
1325 | 691 | "", | ||
1326 | 692 | "", | ||
1327 | 693 | "", | ||
1328 | 694 | "text-file.txt", | ||
1329 | 695 | "text-file.txt" | ||
1330 | 696 | }, | ||
1331 | 697 | { | ||
1332 | 698 | "", | ||
1333 | 699 | "ftp:///a/b/c/file.txt", | ||
1334 | 700 | "ftp:///a/b/c/file.txt", | ||
1335 | 701 | "ftp", | ||
1336 | 702 | 0, | ||
1337 | 703 | "", | ||
1338 | 704 | "", | ||
1339 | 705 | "", | ||
1340 | 706 | "/a/b/c/file.txt", | ||
1341 | 707 | "", | ||
1342 | 708 | "", | ||
1343 | 709 | "/a/b/c/file.txt", | ||
1344 | 710 | "" | ||
1345 | 711 | }, | ||
1346 | 712 | { | ||
1347 | 713 | "", | ||
1348 | 714 | "gopher:///base_dir/file.txt", | ||
1349 | 715 | "gopher:///base_dir/file.txt", | ||
1350 | 716 | "gopher", | ||
1351 | 717 | 0, | ||
1352 | 718 | "", | ||
1353 | 719 | "", | ||
1354 | 720 | "", | ||
1355 | 721 | "/base_dir/file.txt", | ||
1356 | 722 | "", | ||
1357 | 723 | "", | ||
1358 | 724 | "/base_dir/file.txt", | ||
1359 | 725 | "" | ||
1360 | 611 | } | 726 | } |
1361 | 612 | }; // URITestEntry tests[] | 727 | }; // URITestEntry tests[] |
1362 | 613 | 728 | ||
1363 | 614 | 729 | ||
1364 | === modified file 'src/zorbatypes/URI.cpp' | |||
1365 | --- src/zorbatypes/URI.cpp 2013-02-07 17:24:36 +0000 | |||
1366 | +++ src/zorbatypes/URI.cpp 2013-05-03 23:21:27 +0000 | |||
1367 | @@ -474,7 +474,7 @@ | |||
1368 | 474 | : | 474 | : |
1369 | 475 | theState(0), | 475 | theState(0), |
1370 | 476 | thePort(0), | 476 | thePort(0), |
1372 | 477 | valid(validate) | 477 | theValidate(validate) |
1373 | 478 | { | 478 | { |
1374 | 479 | initialize(uri); | 479 | initialize(uri); |
1375 | 480 | 480 | ||
1376 | @@ -489,7 +489,7 @@ | |||
1377 | 489 | : | 489 | : |
1378 | 490 | theState(0), | 490 | theState(0), |
1379 | 491 | thePort(0), | 491 | thePort(0), |
1381 | 492 | valid(validate) | 492 | theValidate(validate) |
1382 | 493 | { | 493 | { |
1383 | 494 | initialize(uri, true); | 494 | initialize(uri, true); |
1384 | 495 | resolve(&base_uri); | 495 | resolve(&base_uri); |
1385 | @@ -503,7 +503,7 @@ | |||
1386 | 503 | : | 503 | : |
1387 | 504 | theState(0), | 504 | theState(0), |
1388 | 505 | thePort(0), | 505 | thePort(0), |
1390 | 506 | valid(false) | 506 | theValidate(false) |
1391 | 507 | { | 507 | { |
1392 | 508 | initialize(full_uri.toString(), false); | 508 | initialize(full_uri.toString(), false); |
1393 | 509 | relativize(&base_uri); | 509 | relativize(&base_uri); |
1394 | @@ -526,7 +526,7 @@ | |||
1395 | 526 | : | 526 | : |
1396 | 527 | theState(0), | 527 | theState(0), |
1397 | 528 | thePort(0), | 528 | thePort(0), |
1399 | 529 | valid(true) | 529 | theValidate(true) |
1400 | 530 | { | 530 | { |
1401 | 531 | } | 531 | } |
1402 | 532 | 532 | ||
1403 | @@ -553,7 +553,7 @@ | |||
1404 | 553 | thePath = to_copy.thePath; | 553 | thePath = to_copy.thePath; |
1405 | 554 | theQueryString = to_copy.theQueryString; | 554 | theQueryString = to_copy.theQueryString; |
1406 | 555 | theFragment = to_copy.theFragment; | 555 | theFragment = to_copy.theFragment; |
1408 | 556 | valid = to_copy.valid; | 556 | theValidate = to_copy.theValidate; |
1409 | 557 | } | 557 | } |
1410 | 558 | 558 | ||
1411 | 559 | 559 | ||
1412 | @@ -572,6 +572,7 @@ | |||
1413 | 572 | thePath.clear(); | 572 | thePath.clear(); |
1414 | 573 | theQueryString.clear(); | 573 | theQueryString.clear(); |
1415 | 574 | theFragment.clear(); | 574 | theFragment.clear(); |
1416 | 575 | theOpaquePart.clear(); | ||
1417 | 575 | 576 | ||
1418 | 576 | // first, we need to normalize the spaces in the uri | 577 | // first, we need to normalize the spaces in the uri |
1419 | 577 | // and only work with the normalized version from this point on | 578 | // and only work with the normalized version from this point on |
1420 | @@ -615,7 +616,7 @@ | |||
1421 | 615 | (lColonIdx > lFragmentIdx && lFragmentIdx != zstring::npos)) | 616 | (lColonIdx > lFragmentIdx && lFragmentIdx != zstring::npos)) |
1422 | 616 | { | 617 | { |
1423 | 617 | // A standalone base is a valid URI | 618 | // A standalone base is a valid URI |
1425 | 618 | if (valid && | 619 | if (theValidate && |
1426 | 619 | (lColonIdx == 0 || (!have_base && lFragmentIdx != zstring::npos)) && | 620 | (lColonIdx == 0 || (!have_base && lFragmentIdx != zstring::npos)) && |
1427 | 620 | lTrimmedURILength > 0) | 621 | lTrimmedURILength > 0) |
1428 | 621 | { | 622 | { |
1429 | @@ -631,11 +632,17 @@ | |||
1430 | 631 | lIndex = (ulong)theScheme.size() + 1; | 632 | lIndex = (ulong)theScheme.size() + 1; |
1431 | 632 | } | 633 | } |
1432 | 633 | 634 | ||
1433 | 635 | if(is_set(Scheme) && (lTrimmedURI.compare(lIndex, 1, "/") != 0)) | ||
1434 | 636 | { | ||
1435 | 637 | // This is an opaque URI. Set that state here; initializePath() will | ||
1436 | 638 | // actually set the value. | ||
1437 | 639 | set_state(OpaquePart); | ||
1438 | 640 | } | ||
1439 | 634 | /** | 641 | /** |
1440 | 635 | * Authority | 642 | * Authority |
1441 | 636 | * two slashes means generic URI syntax, so we get the authority | 643 | * two slashes means generic URI syntax, so we get the authority |
1442 | 637 | */ | 644 | */ |
1444 | 638 | if ( (lTrimmedURI.compare(lIndex, 2, "//") == 0) || | 645 | else if ( (lTrimmedURI.compare(lIndex, 2, "//") == 0) || |
1445 | 639 | // allow JAVA FILE constructs without authority, i.e.: file:/D:/myFile | 646 | // allow JAVA FILE constructs without authority, i.e.: file:/D:/myFile |
1446 | 640 | (ZSTREQ(theScheme, "file") && (lTrimmedURI.compare(lIndex, 1, "/") == 0))) | 647 | (ZSTREQ(theScheme, "file") && (lTrimmedURI.compare(lIndex, 1, "/") == 0))) |
1447 | 641 | { | 648 | { |
1448 | @@ -692,19 +699,16 @@ | |||
1449 | 692 | set_host(zstring()); | 699 | set_host(zstring()); |
1450 | 693 | } | 700 | } |
1451 | 694 | } | 701 | } |
1452 | 695 | // do not allow constructs like: file:D:/myFile or http:myFile | ||
1453 | 696 | } | 702 | } |
1457 | 697 | else if (ZSTREQ(theScheme, "file") || | 703 | // do not allow constructs like: file:D:/myFile or http:myFile |
1458 | 698 | ZSTREQ(theScheme, "http") || | 704 | else if (theValidate && (ZSTREQ(theScheme, "file") || |
1459 | 699 | ZSTREQ(theScheme, "https")) | 705 | ZSTREQ(theScheme, "http") || |
1460 | 706 | ZSTREQ(theScheme, "https") ) ) | ||
1461 | 700 | { | 707 | { |
1469 | 701 | if (valid) | 708 | throw XQUERY_EXCEPTION( |
1470 | 702 | { | 709 | err::XQST0046, |
1471 | 703 | throw XQUERY_EXCEPTION( | 710 | ERROR_PARAMS( lTrimmedURI, ZED( BadURISyntaxForScheme_3 ), theScheme ) |
1472 | 704 | err::XQST0046, | 711 | ); |
1466 | 705 | ERROR_PARAMS( lTrimmedURI, ZED( BadURISyntaxForScheme_3 ), theScheme ) | ||
1467 | 706 | ); | ||
1468 | 707 | } | ||
1473 | 708 | } | 712 | } |
1474 | 709 | 713 | ||
1475 | 710 | // stop, if we're done here | 714 | // stop, if we're done here |
1476 | @@ -727,7 +731,7 @@ | |||
1477 | 727 | { | 731 | { |
1478 | 728 | zstring::size_type lSchemeSeparatorIdx = uri.find_first_of(":/?#", 0,4 ); | 732 | zstring::size_type lSchemeSeparatorIdx = uri.find_first_of(":/?#", 0,4 ); |
1479 | 729 | 733 | ||
1481 | 730 | if ( valid && lSchemeSeparatorIdx == zstring::npos ) | 734 | if ( theValidate && lSchemeSeparatorIdx == zstring::npos ) |
1482 | 731 | { | 735 | { |
1483 | 732 | throw XQUERY_EXCEPTION( | 736 | throw XQUERY_EXCEPTION( |
1484 | 733 | err::XQST0046, ERROR_PARAMS( uri, ZED( NoURIScheme ) ) | 737 | err::XQST0046, ERROR_PARAMS( uri, ZED( NoURIScheme ) ) |
1485 | @@ -919,18 +923,12 @@ | |||
1486 | 919 | ulong lEnd = (ulong)lCodepoints.size(); | 923 | ulong lEnd = (ulong)lCodepoints.size(); |
1487 | 920 | uint32_t lCp = 0; | 924 | uint32_t lCp = 0; |
1488 | 921 | 925 | ||
1495 | 922 | if (uri.empty()) | 926 | bool lIsOpaque = is_set(OpaquePart); |
1490 | 923 | { | ||
1491 | 924 | thePath = uri; | ||
1492 | 925 | set_state(Path); | ||
1493 | 926 | return; | ||
1494 | 927 | } | ||
1496 | 928 | 927 | ||
1498 | 929 | // path - everything up to query string or fragment | 928 | // path - everything up to query string (if not opaque) or fragment |
1499 | 930 | if ( lStart < lEnd ) | 929 | if ( lStart < lEnd ) |
1500 | 931 | { | 930 | { |
1503 | 932 | // RFC 2732 only allows '[' and ']' to appear in the opaque part. | 931 | if ( ! is_set(Scheme) || lIsOpaque || lCodepoints[lStart] == '/') |
1502 | 933 | if ( ! is_set(Scheme) || lCodepoints[lStart] == '/') | ||
1504 | 934 | { | 932 | { |
1505 | 935 | // Scan path. | 933 | // Scan path. |
1506 | 936 | // abs_path = "/" path_segments | 934 | // abs_path = "/" path_segments |
1507 | @@ -938,11 +936,20 @@ | |||
1508 | 938 | while ( lIndex < lEnd ) | 936 | while ( lIndex < lEnd ) |
1509 | 939 | { | 937 | { |
1510 | 940 | lCp = lCodepoints[lIndex]; | 938 | lCp = lCodepoints[lIndex]; |
1512 | 941 | if ( lCp == '?' || lCp == '#' ) | 939 | if (lCp == '?') { |
1513 | 940 | if ( ! lIsOpaque) { | ||
1514 | 941 | // Query string starting if not opaque | ||
1515 | 942 | break; | ||
1516 | 943 | } | ||
1517 | 944 | // If it is an opaque URI, ? is fine | ||
1518 | 945 | } | ||
1519 | 946 | else if (lCp == '#' ) { | ||
1520 | 947 | // Fragment starting | ||
1521 | 942 | break; | 948 | break; |
1524 | 943 | 949 | } | |
1525 | 944 | if ( lCp == '%' ) | 950 | else if ( lCp == '%' ) |
1526 | 945 | { | 951 | { |
1527 | 952 | // Percent-decoding check | ||
1528 | 946 | if ( lIndex + 2 >= lEnd ) | 953 | if ( lIndex + 2 >= lEnd ) |
1529 | 947 | { | 954 | { |
1530 | 948 | throw XQUERY_EXCEPTION(err::XQST0046, | 955 | throw XQUERY_EXCEPTION(err::XQST0046, |
1531 | @@ -965,7 +972,7 @@ | |||
1532 | 965 | ERROR_PARAMS(uri, ZED(XQST0046_BadHexDigit_3), lHex2)); | 972 | ERROR_PARAMS(uri, ZED(XQST0046_BadHexDigit_3), lHex2)); |
1533 | 966 | } | 973 | } |
1534 | 967 | } | 974 | } |
1536 | 968 | else if (!is_unreserved_char(lCp) && !is_path_character(lCp) && valid) | 975 | else if (theValidate && !is_unreserved_char(lCp) && !is_path_character(lCp)) |
1537 | 969 | { | 976 | { |
1538 | 970 | throw XQUERY_EXCEPTION(err::XQST0046, | 977 | throw XQUERY_EXCEPTION(err::XQST0046, |
1539 | 971 | ERROR_PARAMS(uri, ZED(BadUnicodeChar_3), lCp)); | 978 | ERROR_PARAMS(uri, ZED(BadUnicodeChar_3), lCp)); |
1540 | @@ -992,7 +999,7 @@ | |||
1541 | 992 | { | 999 | { |
1542 | 993 | // TODO check errors | 1000 | // TODO check errors |
1543 | 994 | } | 1001 | } |
1545 | 995 | else if (!is_reservered_or_unreserved_char(lCp) && valid) | 1002 | else if (!is_reservered_or_unreserved_char(lCp) && theValidate) |
1546 | 996 | { | 1003 | { |
1547 | 997 | throw XQUERY_EXCEPTION( | 1004 | throw XQUERY_EXCEPTION( |
1548 | 998 | err::XQST0046, ERROR_PARAMS( uri, ZED( BadUnicodeChar_3 ), lCp ) | 1005 | err::XQST0046, ERROR_PARAMS( uri, ZED( BadUnicodeChar_3 ), lCp ) |
1549 | @@ -1005,15 +1012,23 @@ | |||
1550 | 1005 | } // lStart < lEnd | 1012 | } // lStart < lEnd |
1551 | 1006 | 1013 | ||
1552 | 1007 | 1014 | ||
1559 | 1008 | thePath.clear(); | 1015 | // lCodepoints now contains all the processed stuff; put it in the right place |
1560 | 1009 | utf8::append_codepoints(lCodepoints.begin() + lStart, | 1016 | if (lIsOpaque) { |
1561 | 1010 | lCodepoints.begin() + lIndex, | 1017 | theOpaquePart.clear(); |
1562 | 1011 | &thePath); | 1018 | utf8::append_codepoints(lCodepoints.begin() + lStart, |
1563 | 1012 | 1019 | lCodepoints.begin() + lIndex, | |
1564 | 1013 | set_state(Path); | 1020 | &theOpaquePart); |
1565 | 1021 | } | ||
1566 | 1022 | else { | ||
1567 | 1023 | thePath.clear(); | ||
1568 | 1024 | utf8::append_codepoints(lCodepoints.begin() + lStart, | ||
1569 | 1025 | lCodepoints.begin() + lIndex, | ||
1570 | 1026 | &thePath); | ||
1571 | 1027 | set_state(Path); | ||
1572 | 1028 | } | ||
1573 | 1014 | 1029 | ||
1574 | 1015 | // query - starts with ? and up to fragment or end | 1030 | // query - starts with ? and up to fragment or end |
1576 | 1016 | if ( lCp == '?' ) | 1031 | if ( ( ! lIsOpaque) && (lCp == '?') ) |
1577 | 1017 | { | 1032 | { |
1578 | 1018 | ++lIndex; | 1033 | ++lIndex; |
1579 | 1019 | lStart = lIndex; | 1034 | lStart = lIndex; |
1580 | @@ -1159,6 +1174,28 @@ | |||
1581 | 1159 | } | 1174 | } |
1582 | 1160 | } | 1175 | } |
1583 | 1161 | 1176 | ||
1584 | 1177 | /******************************************************************************* | ||
1585 | 1178 | |||
1586 | 1179 | ********************************************************************************/ | ||
1587 | 1180 | void URI::set_query(const zstring& new_query) | ||
1588 | 1181 | { | ||
1589 | 1182 | theQueryString = new_query; | ||
1590 | 1183 | set_state(QueryString); | ||
1591 | 1184 | } | ||
1592 | 1185 | |||
1593 | 1186 | void URI::set_opaque_part(const zstring& new_scheme_specific) | ||
1594 | 1187 | { | ||
1595 | 1188 | if (new_scheme_specific.empty()) | ||
1596 | 1189 | { | ||
1597 | 1190 | theOpaquePart = new_scheme_specific; | ||
1598 | 1191 | unset_state(OpaquePart); | ||
1599 | 1192 | } | ||
1600 | 1193 | else | ||
1601 | 1194 | { | ||
1602 | 1195 | theOpaquePart = new_scheme_specific; | ||
1603 | 1196 | set_state(OpaquePart); | ||
1604 | 1197 | } | ||
1605 | 1198 | } | ||
1606 | 1162 | 1199 | ||
1607 | 1163 | /******************************************************************************* | 1200 | /******************************************************************************* |
1608 | 1164 | 1201 | ||
1609 | @@ -1287,7 +1324,7 @@ | |||
1610 | 1287 | set_state(Path); | 1324 | set_state(Path); |
1611 | 1288 | } | 1325 | } |
1612 | 1289 | 1326 | ||
1614 | 1290 | if ( (! is_set(QueryString)) ) | 1327 | if ( base_uri->is_set(QueryString) && !is_set(QueryString) ) |
1615 | 1291 | { | 1328 | { |
1616 | 1292 | base_uri->get_query(theQueryString); | 1329 | base_uri->get_query(theQueryString); |
1617 | 1293 | 1330 | ||
1618 | @@ -1584,6 +1621,13 @@ | |||
1619 | 1584 | std::ostringstream lPathNotation; | 1621 | std::ostringstream lPathNotation; |
1620 | 1585 | 1622 | ||
1621 | 1586 | std::string lToTokenize; | 1623 | std::string lToTokenize; |
1622 | 1624 | |||
1623 | 1625 | if(is_set(OpaquePart)) | ||
1624 | 1626 | { | ||
1625 | 1627 | thePathNotation = theOpaquePart.str(); | ||
1626 | 1628 | return; | ||
1627 | 1629 | } | ||
1628 | 1630 | |||
1629 | 1587 | if (is_set(Host)) | 1631 | if (is_set(Host)) |
1630 | 1588 | { | 1632 | { |
1631 | 1589 | lToTokenize = theHost.str(); | 1633 | lToTokenize = theHost.str(); |
1632 | @@ -1593,7 +1637,7 @@ | |||
1633 | 1593 | lToTokenize = theRegBasedAuthority.str(); | 1637 | lToTokenize = theRegBasedAuthority.str(); |
1634 | 1594 | } | 1638 | } |
1635 | 1595 | 1639 | ||
1637 | 1596 | std::string::size_type lastPos = | 1640 | std::string::size_type lastPos = |
1638 | 1597 | lToTokenize.find_last_not_of(".", lToTokenize.length()); | 1641 | lToTokenize.find_last_not_of(".", lToTokenize.length()); |
1639 | 1598 | 1642 | ||
1640 | 1599 | std::string::size_type pos = lToTokenize.find_last_of(".", lastPos); | 1643 | std::string::size_type pos = lToTokenize.find_last_of(".", lastPos); |
1641 | @@ -1637,37 +1681,45 @@ | |||
1642 | 1637 | if ( is_set(Scheme) ) | 1681 | if ( is_set(Scheme) ) |
1643 | 1638 | lURI << theScheme << ":"; | 1682 | lURI << theScheme << ":"; |
1644 | 1639 | 1683 | ||
1676 | 1640 | // Authority | 1684 | if(is_set(OpaquePart)) |
1677 | 1641 | if ( is_set(Host) || is_set(RegBasedAuthority) ) | 1685 | { |
1678 | 1642 | { | 1686 | // opaque URL |
1679 | 1643 | lURI << "//"; | 1687 | lURI << theOpaquePart; |
1680 | 1644 | if ( is_set(Host) ) | 1688 | } |
1681 | 1645 | { | 1689 | else |
1682 | 1646 | if ( is_set(UserInfo) ) | 1690 | { |
1683 | 1647 | lURI << theUserInfo << "@"; | 1691 | // Authority |
1684 | 1648 | 1692 | if ( is_set(Host) || is_set(RegBasedAuthority) ) | |
1685 | 1649 | lURI << theHost; | 1693 | { |
1686 | 1650 | 1694 | lURI << "//"; | |
1687 | 1651 | if ( is_set(Port) ) | 1695 | if ( is_set(Host) ) |
1688 | 1652 | lURI << ":" << thePort; | 1696 | { |
1689 | 1653 | } | 1697 | if ( is_set(UserInfo) ) |
1690 | 1654 | else | 1698 | lURI << theUserInfo << "@"; |
1691 | 1655 | { | 1699 | |
1692 | 1656 | lURI << theRegBasedAuthority; | 1700 | lURI << theHost; |
1693 | 1657 | } | 1701 | |
1694 | 1658 | } | 1702 | if ( is_set(Port) ) |
1695 | 1659 | 1703 | lURI << ":" << thePort; | |
1696 | 1660 | if ( is_set(Path) ) | 1704 | } |
1697 | 1661 | { | 1705 | else |
1698 | 1662 | #ifdef WIN32 | 1706 | { |
1699 | 1663 | if(ZSTREQ(theScheme, "file") && !thePath.empty() && (thePath[0] != '/')) | 1707 | lURI << theRegBasedAuthority; |
1700 | 1664 | lURI << "/"; | 1708 | } |
1701 | 1665 | #endif | 1709 | } |
1702 | 1666 | lURI << thePath; | 1710 | |
1703 | 1667 | } | 1711 | if ( is_set(Path) ) |
1704 | 1668 | 1712 | { | |
1705 | 1669 | if ( is_set(QueryString) ) | 1713 | #ifdef WIN32 |
1706 | 1670 | lURI << "?" << theQueryString; | 1714 | if(ZSTREQ(theScheme, "file") && !thePath.empty() && (thePath[0] != '/')) |
1707 | 1715 | lURI << "/"; | ||
1708 | 1716 | #endif | ||
1709 | 1717 | lURI << thePath; | ||
1710 | 1718 | } | ||
1711 | 1719 | |||
1712 | 1720 | if ( is_set(QueryString) ) | ||
1713 | 1721 | lURI << "?" << theQueryString; | ||
1714 | 1722 | } | ||
1715 | 1671 | 1723 | ||
1716 | 1672 | if ( is_set(Fragment) ) | 1724 | if ( is_set(Fragment) ) |
1717 | 1673 | lURI << "#" << theFragment; | 1725 | lURI << "#" << theFragment; |
1718 | @@ -1687,38 +1739,46 @@ | |||
1719 | 1687 | if ( is_set(Scheme) ) | 1739 | if ( is_set(Scheme) ) |
1720 | 1688 | lURI << theScheme << ":"; | 1740 | lURI << theScheme << ":"; |
1721 | 1689 | 1741 | ||
1754 | 1690 | // Authority | 1742 | if (is_set(OpaquePart)) |
1755 | 1691 | if ( is_set(Host) || is_set(RegBasedAuthority) ) | 1743 | { |
1756 | 1692 | { | 1744 | // opaque uri |
1757 | 1693 | lURI << "//"; | 1745 | lURI << theOpaquePart; |
1758 | 1694 | 1746 | } | |
1759 | 1695 | if ( is_set(Host) ) | 1747 | else |
1760 | 1696 | { | 1748 | { |
1761 | 1697 | if ( is_set(UserInfo) ) | 1749 | // Authority |
1762 | 1698 | lURI << theUserInfo << "@"; | 1750 | if ( is_set(Host) || is_set(RegBasedAuthority) ) |
1763 | 1699 | 1751 | { | |
1764 | 1700 | lURI << theHost; | 1752 | lURI << "//"; |
1765 | 1701 | 1753 | ||
1766 | 1702 | if ( is_set(Port) ) | 1754 | if ( is_set(Host) ) |
1767 | 1703 | lURI << ":" << thePort; | 1755 | { |
1768 | 1704 | } | 1756 | if ( is_set(UserInfo) ) |
1769 | 1705 | else | 1757 | lURI << theUserInfo << "@"; |
1770 | 1706 | { | 1758 | |
1771 | 1707 | lURI << theRegBasedAuthority; | 1759 | lURI << theHost; |
1772 | 1708 | } | 1760 | |
1773 | 1709 | } | 1761 | if ( is_set(Port) ) |
1774 | 1710 | 1762 | lURI << ":" << thePort; | |
1775 | 1711 | if ( is_set(Path) ) | 1763 | } |
1776 | 1712 | { | 1764 | else |
1777 | 1713 | #ifdef WIN32 | 1765 | { |
1778 | 1714 | if(ZSTREQ(theScheme, "file") && !thePath.empty() && (thePath[0] != '/')) | 1766 | lURI << theRegBasedAuthority; |
1779 | 1715 | lURI << "/"; | 1767 | } |
1780 | 1716 | #endif | 1768 | } |
1781 | 1717 | lURI << thePath; | 1769 | |
1782 | 1718 | } | 1770 | if ( is_set(Path) ) |
1783 | 1719 | 1771 | { | |
1784 | 1720 | if ( is_set(QueryString) ) | 1772 | #ifdef WIN32 |
1785 | 1721 | lURI << "?" << theQueryString; | 1773 | if(ZSTREQ(theScheme, "file") && !thePath.empty() && (thePath[0] != '/')) |
1786 | 1774 | lURI << "/"; | ||
1787 | 1775 | #endif | ||
1788 | 1776 | lURI << thePath; | ||
1789 | 1777 | } | ||
1790 | 1778 | |||
1791 | 1779 | if ( is_set(QueryString) ) | ||
1792 | 1780 | lURI << "?" << theQueryString; | ||
1793 | 1781 | } | ||
1794 | 1722 | 1782 | ||
1795 | 1723 | if ( is_set(Fragment) ) | 1783 | if ( is_set(Fragment) ) |
1796 | 1724 | lURI << "#" << theFragment; | 1784 | lURI << "#" << theFragment; |
1797 | 1725 | 1785 | ||
1798 | === modified file 'src/zorbatypes/URI.h' | |||
1799 | --- src/zorbatypes/URI.h 2013-02-07 17:24:36 +0000 | |||
1800 | +++ src/zorbatypes/URI.h 2013-05-03 23:21:27 +0000 | |||
1801 | @@ -49,19 +49,20 @@ | |||
1802 | 49 | 49 | ||
1803 | 50 | static long scanHexSequence(const char* addr, long idx, long end, long& counter); | 50 | static long scanHexSequence(const char* addr, long idx, long end, long& counter); |
1804 | 51 | 51 | ||
1805 | 52 | protected: | ||
1806 | 53 | enum States | 52 | enum States |
1807 | 54 | { | 53 | { |
1816 | 55 | Scheme = 1, | 54 | Scheme = 1, |
1817 | 56 | UserInfo = 2, | 55 | UserInfo = 2, |
1818 | 57 | Host = 4, | 56 | Host = 4, |
1819 | 58 | Port = 8, | 57 | Port = 8, |
1820 | 59 | RegBasedAuthority = 16, | 58 | RegBasedAuthority = 16, |
1821 | 60 | Path = 32, | 59 | Path = 32, |
1822 | 61 | QueryString = 64, | 60 | QueryString = 64, |
1823 | 62 | Fragment = 128 | 61 | Fragment = 128, |
1824 | 62 | OpaquePart = 256 | ||
1825 | 63 | }; | 63 | }; |
1826 | 64 | 64 | ||
1827 | 65 | protected: | ||
1828 | 65 | // keep track whether particular components of a uri are defined or undefined | 66 | // keep track whether particular components of a uri are defined or undefined |
1829 | 66 | mutable uint32_t theState; | 67 | mutable uint32_t theState; |
1830 | 67 | 68 | ||
1831 | @@ -81,9 +82,10 @@ | |||
1832 | 81 | zstring thePath; | 82 | zstring thePath; |
1833 | 82 | zstring theQueryString; | 83 | zstring theQueryString; |
1834 | 83 | zstring theFragment; | 84 | zstring theFragment; |
1835 | 85 | zstring theOpaquePart; | ||
1836 | 84 | 86 | ||
1837 | 85 | // true if the constructed URI is valid | 87 | // true if the constructed URI is valid |
1839 | 86 | bool valid; | 88 | bool theValidate; |
1840 | 87 | 89 | ||
1841 | 88 | public: | 90 | public: |
1842 | 89 | URI(const zstring& uri, bool validate = true); | 91 | URI(const zstring& uri, bool validate = true); |
1843 | @@ -154,6 +156,14 @@ | |||
1844 | 154 | 156 | ||
1845 | 155 | void clear_fragment(); | 157 | void clear_fragment(); |
1846 | 156 | 158 | ||
1847 | 159 | void set_opaque_part(const zstring& new_opaque_part); | ||
1848 | 160 | |||
1849 | 161 | const zstring& get_opaque_part() const; | ||
1850 | 162 | |||
1851 | 163 | void clear_opaque_part(); | ||
1852 | 164 | |||
1853 | 165 | bool is_set(uint32_t s) const { return ((theState & s) > 0); } | ||
1854 | 166 | |||
1855 | 157 | protected: | 167 | protected: |
1856 | 158 | void build_full_text() const; | 168 | void build_full_text() const; |
1857 | 159 | 169 | ||
1858 | @@ -185,8 +195,6 @@ | |||
1859 | 185 | 195 | ||
1860 | 186 | void set_state(uint32_t s) const { theState |= s; } | 196 | void set_state(uint32_t s) const { theState |= s; } |
1861 | 187 | 197 | ||
1862 | 188 | bool is_set(uint32_t s) const { return ((theState & s) > 0); } | ||
1863 | 189 | |||
1864 | 190 | void unset_state(uint32_t s) const { theState &= ~s; } | 198 | void unset_state(uint32_t s) const { theState &= ~s; } |
1865 | 191 | 199 | ||
1866 | 192 | void invalidate_text() const; | 200 | void invalidate_text() const; |
1867 | @@ -195,7 +203,9 @@ | |||
1868 | 195 | 203 | ||
1869 | 196 | inline bool URI::is_valid() const | 204 | inline bool URI::is_valid() const |
1870 | 197 | { | 205 | { |
1872 | 198 | return valid; | 206 | // If we requested validation originally, and successfully passed the |
1873 | 207 | // initialize step - we're valid! | ||
1874 | 208 | return theValidate; | ||
1875 | 199 | } | 209 | } |
1876 | 200 | 210 | ||
1877 | 201 | 211 | ||
1878 | @@ -246,9 +256,15 @@ | |||
1879 | 246 | return theFragment; | 256 | return theFragment; |
1880 | 247 | } | 257 | } |
1881 | 248 | 258 | ||
1882 | 259 | inline const zstring& URI::get_opaque_part() const | ||
1883 | 260 | { | ||
1884 | 261 | return theOpaquePart; | ||
1885 | 262 | } | ||
1886 | 263 | |||
1887 | 249 | inline void URI::set_fragment(const zstring &new_fragment) | 264 | inline void URI::set_fragment(const zstring &new_fragment) |
1888 | 250 | { | 265 | { |
1889 | 251 | theFragment = new_fragment; | 266 | theFragment = new_fragment; |
1890 | 267 | set_state(Fragment); | ||
1891 | 252 | invalidate_text(); | 268 | invalidate_text(); |
1892 | 253 | } | 269 | } |
1893 | 254 | 270 | ||
1894 | @@ -259,6 +275,13 @@ | |||
1895 | 259 | invalidate_text(); | 275 | invalidate_text(); |
1896 | 260 | } | 276 | } |
1897 | 261 | 277 | ||
1898 | 278 | inline void URI::clear_opaque_part() | ||
1899 | 279 | { | ||
1900 | 280 | theOpaquePart.clear(); | ||
1901 | 281 | unset_state(OpaquePart); | ||
1902 | 282 | invalidate_text(); | ||
1903 | 283 | } | ||
1904 | 284 | |||
1905 | 262 | inline void URI::invalidate_text() const | 285 | inline void URI::invalidate_text() const |
1906 | 263 | { | 286 | { |
1907 | 264 | theASCIIURIText.clear(); | 287 | theASCIIURIText.clear(); |
1908 | 265 | 288 | ||
1909 | === modified file 'test/fots/CMakeLists.txt' | |||
1910 | --- test/fots/CMakeLists.txt 2013-05-03 07:40:27 +0000 | |||
1911 | +++ test/fots/CMakeLists.txt 2013-05-03 23:21:27 +0000 | |||
1912 | @@ -303,7 +303,6 @@ | |||
1913 | 303 | EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-12 0) | 303 | EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-12 0) |
1914 | 304 | EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-17 0) | 304 | EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-17 0) |
1915 | 305 | EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-18 0) | 305 | EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-18 0) |
1916 | 306 | EXPECTED_FOTS_FAILURE (prod-ModuleImport module-URIs-19 0) | ||
1917 | 307 | EXPECTED_FOTS_FAILURE (prod-ModuleImport modules-collide-var-001 0) | 306 | EXPECTED_FOTS_FAILURE (prod-ModuleImport modules-collide-var-001 0) |
1918 | 308 | EXPECTED_FOTS_FAILURE (prod-ModuleImport modules-collide-fn-001 0) | 307 | EXPECTED_FOTS_FAILURE (prod-ModuleImport modules-collide-fn-001 0) |
1919 | 309 | EXPECTED_FOTS_FAILURE (prod-ModuleImport errata8-002a 0) | 308 | EXPECTED_FOTS_FAILURE (prod-ModuleImport errata8-002a 0) |
1920 | 310 | 309 | ||
1921 | === added file 'test/rbkt/ExpQueryResults/zorba/uris/parse-uri.xml.res' | |||
1922 | --- test/rbkt/ExpQueryResults/zorba/uris/parse-uri.xml.res 1970-01-01 00:00:00 +0000 | |||
1923 | +++ test/rbkt/ExpQueryResults/zorba/uris/parse-uri.xml.res 2013-05-03 23:21:27 +0000 | |||
1924 | @@ -0,0 +1,1 @@ | |||
1925 | 1 | { "scheme" : "http", "path" : "/" }{ "scheme" : "http", "host" : "www.zorba-xquery.com", "path" : "/" }{ "scheme" : "http", "host" : "www.zorba-xquery.com", "path" : "/", "query" : "abc=true" }{ "scheme" : "http", "host" : "www.zorba-xquery.com", "port" : 8080, "path" : "/", "query" : "abc=true" }{ "scheme" : "http", "user-info" : "user", "host" : "www.zorba-xquery.com", "port" : 8080, "path" : "/", "query" : "abc=true" }{ "scheme" : "http", "user-info" : "user", "host" : "www.zorba-xquery.com", "port" : 8080, "path" : "/path1/path2", "query" : "abc=true" }{ "scheme" : "http", "user-info" : "user", "host" : "www.zorba-xquery.com", "port" : 8080, "path" : "/path1/path2", "query" : "abc=true&bcd=false", "fragment" : "fragment" }{ "scheme" : "ftp", "host" : "ftp.is.co.za", "path" : "/rfc/rfc1808.txt" }{ "scheme" : "http", "user-info" : "thomas", "host" : "[2001:6f8:9000:876:cccc:bbbb::]", "port" : 123, "path" : "/test" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g/" }{ "scheme" : "http", "host" : "a", "path" : "/g" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/", "query" : "y" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g", "query" : "y" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g", "fragment" : "s" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g", "query" : "y", "fragment" : "s" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/;x" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g;x" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g;x", "query" : "y", "fragment" : "s" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/" }{ "scheme" : "http", "host" : "a", "path" : "/b/" }{ "scheme" : "http", "host" : "a", "path" : "/b/" }{ "scheme" : "http", "host" : "a", "path" : "/b/g" }{ "scheme" : "http", "host" : "a", "path" : "/" }{ "scheme" : "http", "host" : "a", "path" : "/" }{ "scheme" : "http", "host" : "a", "path" : "/g" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g;x=1/y" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/y" }{ "scheme" : "http", "host" : "a", "path" : "/b/c/g", "fragment" : "s/../x" }{ "scheme" : "http", "host" : "www.example.com", "path" : "/" }{ "scheme" : "http", "host" : "www.example.com", "path" : "/dir/file" }{ "scheme" : "http", "host" : "www.msb.de" }{ "scheme" : "http", "host" : "www.msb.de", "path" : "/lib/helpers" }{ "scheme" : "file", "path" : "/d:/a/b/c" }{ "scheme" : "file", "host" : "localhost", "path" : "/d:/a/b/c" }{ "scheme" : "file", "host" : "localhost", "path" : "/Ångström/b/c" }{ "scheme" : "file", "opaque-part" : "opaque-uri-part", "fragment" : "frag" }{ "scheme" : "file", "opaque-part" : "text-file.txt" }{ "scheme" : "file", "opaque-part" : "bar?" }{ "scheme" : "file", "opaque-part" : "bar?", "fragment" : "frag" }{ "scheme" : "http", "host" : "foo.com", "path" : "/bc", "query" : "" } | ||
1926 | 0 | \ No newline at end of file | 2 | \ No newline at end of file |
1927 | 1 | 3 | ||
1928 | === added file 'test/rbkt/ExpQueryResults/zorba/uris/serialize-direct-uri.xml.res' | |||
1929 | --- test/rbkt/ExpQueryResults/zorba/uris/serialize-direct-uri.xml.res 1970-01-01 00:00:00 +0000 | |||
1930 | +++ test/rbkt/ExpQueryResults/zorba/uris/serialize-direct-uri.xml.res 2013-05-03 23:21:27 +0000 | |||
1931 | @@ -0,0 +1,37 @@ | |||
1932 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
1933 | 2 | http:/ | ||
1934 | 3 | http://www.zorba-xquery.com/ | ||
1935 | 4 | http://www.zorba-xquery.com/?abc=true | ||
1936 | 5 | http://www.zorba-xquery.com:8080/?abc=true | ||
1937 | 6 | http://user@www.zorba-xquery.com:8080/?abc=true | ||
1938 | 7 | http://user@www.zorba-xquery.com:8080/path1/path2?abc=true | ||
1939 | 8 | http://user@www.zorba-xquery.com:8080/path1/path2?abc=true&bcd=false | ||
1940 | 9 | ftp://ftp.is.co.za/rfc/rfc1808.txt | ||
1941 | 10 | http://thomas@[2001:6f8:9000:876:cccc:bbbb::]:123/test | ||
1942 | 11 | http://a/b/c/g | ||
1943 | 12 | http://a/b/c/g/ | ||
1944 | 13 | http://a/g | ||
1945 | 14 | http://a/b/c/?y | ||
1946 | 15 | http://a/b/c/g?y | ||
1947 | 16 | http://a/b/c/g#s | ||
1948 | 17 | http://a/b/c/g?y#s | ||
1949 | 18 | http://a/b/c/;x | ||
1950 | 19 | http://a/b/c/g;x | ||
1951 | 20 | http://a/b/c/g;x?y#s | ||
1952 | 21 | http://a/b/c | ||
1953 | 22 | http://a/b/c/ | ||
1954 | 23 | http://a/b | ||
1955 | 24 | http://a/b/ | ||
1956 | 25 | http://a/b/g | ||
1957 | 26 | http://a/ | ||
1958 | 27 | http://a/g | ||
1959 | 28 | http://a/b/c/g;x=1/y | ||
1960 | 29 | http://a/b/c/y | ||
1961 | 30 | http://a/b/c/g#s/../x | ||
1962 | 31 | http://www.example.com/ | ||
1963 | 32 | http://www.example.com/dir/file | ||
1964 | 33 | http://www.msb.de | ||
1965 | 34 | http://www.msb.de/lib/helpers | ||
1966 | 35 | file://localhost/Ångström/b/c | ||
1967 | 36 | file:opaque-uri-part#frag | ||
1968 | 37 | file:text-file.txt | ||
1969 | 0 | 38 | ||
1970 | === added file 'test/rbkt/ExpQueryResults/zorba/uris/serialize-uri.xml.res' | |||
1971 | --- test/rbkt/ExpQueryResults/zorba/uris/serialize-uri.xml.res 1970-01-01 00:00:00 +0000 | |||
1972 | +++ test/rbkt/ExpQueryResults/zorba/uris/serialize-uri.xml.res 2013-05-03 23:21:27 +0000 | |||
1973 | @@ -0,0 +1,44 @@ | |||
1974 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
1975 | 2 | http:/ | ||
1976 | 3 | http://www.zorba-xquery.com/ | ||
1977 | 4 | http://www.zorba-xquery.com/?abc=true | ||
1978 | 5 | http://www.zorba-xquery.com:8080/?abc=true | ||
1979 | 6 | http://user@www.zorba-xquery.com:8080/?abc=true | ||
1980 | 7 | http://user@www.zorba-xquery.com:8080/path1/path2?abc=true | ||
1981 | 8 | http://user@www.zorba-xquery.com:8080/path1/path2?abc=true&bcd=false#fragment | ||
1982 | 9 | ftp://ftp.is.co.za/rfc/rfc1808.txt | ||
1983 | 10 | http://thomas@[2001:6f8:9000:876:cccc:bbbb::]:123/test | ||
1984 | 11 | http://a/b/c/g | ||
1985 | 12 | http://a/b/c/g | ||
1986 | 13 | http://a/b/c/g/ | ||
1987 | 14 | http://a/g | ||
1988 | 15 | http://a/b/c/?y | ||
1989 | 16 | http://a/b/c/g?y | ||
1990 | 17 | http://a/b/c/g#s | ||
1991 | 18 | http://a/b/c/g?y#s | ||
1992 | 19 | http://a/b/c/;x | ||
1993 | 20 | http://a/b/c/g;x | ||
1994 | 21 | http://a/b/c/g;x?y#s | ||
1995 | 22 | http://a/b/c/ | ||
1996 | 23 | http://a/b/c/ | ||
1997 | 24 | http://a/b/ | ||
1998 | 25 | http://a/b/ | ||
1999 | 26 | http://a/b/g | ||
2000 | 27 | http://a/ | ||
2001 | 28 | http://a/ | ||
2002 | 29 | http://a/g | ||
2003 | 30 | http://a/b/c/g;x=1/y | ||
2004 | 31 | http://a/b/c/y | ||
2005 | 32 | http://a/b/c/g#s/../x | ||
2006 | 33 | http://www.example.com/ | ||
2007 | 34 | http://www.example.com/dir/file | ||
2008 | 35 | http://www.msb.de | ||
2009 | 36 | http://www.msb.de/lib/helpers | ||
2010 | 37 | file:/d:/a/b/c | ||
2011 | 38 | file://localhost/d:/a/b/c | ||
2012 | 39 | file://localhost/Ångström/b/c | ||
2013 | 40 | file:opaque-uri-part#frag | ||
2014 | 41 | file:text-file.txt | ||
2015 | 42 | file:bar? | ||
2016 | 43 | file:bar?#frag | ||
2017 | 44 | http://foo.com/bc? | ||
2018 | 0 | \ No newline at end of file | 45 | \ No newline at end of file |
2019 | 1 | 46 | ||
2020 | === added file 'test/rbkt/Queries/zorba/uris/parse-invalid.spec' | |||
2021 | --- test/rbkt/Queries/zorba/uris/parse-invalid.spec 1970-01-01 00:00:00 +0000 | |||
2022 | +++ test/rbkt/Queries/zorba/uris/parse-invalid.spec 2013-05-03 23:21:27 +0000 | |||
2023 | @@ -0,0 +1,1 @@ | |||
2024 | 1 | Error: http://www.w3.org/2005/xqt-errors:XQST0046 | ||
2025 | 0 | 2 | ||
2026 | === added file 'test/rbkt/Queries/zorba/uris/parse-invalid.xq' | |||
2027 | --- test/rbkt/Queries/zorba/uris/parse-invalid.xq 1970-01-01 00:00:00 +0000 | |||
2028 | +++ test/rbkt/Queries/zorba/uris/parse-invalid.xq 2013-05-03 23:21:27 +0000 | |||
2029 | @@ -0,0 +1,3 @@ | |||
2030 | 1 | import module namespace uri="http://www.zorba-xquery.com/modules/uri"; | ||
2031 | 2 | |||
2032 | 3 | uri:parse("foo:bar%%") | ||
2033 | 0 | 4 | ||
2034 | === added file 'test/rbkt/Queries/zorba/uris/parse-uri.xq' | |||
2035 | --- test/rbkt/Queries/zorba/uris/parse-uri.xq 1970-01-01 00:00:00 +0000 | |||
2036 | +++ test/rbkt/Queries/zorba/uris/parse-uri.xq 2013-05-03 23:21:27 +0000 | |||
2037 | @@ -0,0 +1,6 @@ | |||
2038 | 1 | import module namespace uri = "http://www.zorba-xquery.com/modules/uri"; | ||
2039 | 2 | |||
2040 | 3 | let $xml-uri-test := fn:doc("uri-source.xml")//uri-element/text() | ||
2041 | 4 | |||
2042 | 5 | for $uri in $xml-uri-test | ||
2043 | 6 | return uri:parse($uri) | ||
2044 | 0 | 7 | ||
2045 | === added file 'test/rbkt/Queries/zorba/uris/serialize-direct-uri.xq' | |||
2046 | --- test/rbkt/Queries/zorba/uris/serialize-direct-uri.xq 1970-01-01 00:00:00 +0000 | |||
2047 | +++ test/rbkt/Queries/zorba/uris/serialize-direct-uri.xq 2013-05-03 23:21:27 +0000 | |||
2048 | @@ -0,0 +1,211 @@ | |||
2049 | 1 | import module namespace uri = "http://www.zorba-xquery.com/modules/uri"; | ||
2050 | 2 | |||
2051 | 3 | let $xml-uri-test := { "uri-test" : | ||
2052 | 4 | [ | ||
2053 | 5 | { | ||
2054 | 6 | $uri:SCHEME : "http", | ||
2055 | 7 | $uri:PATH : "/" | ||
2056 | 8 | }, | ||
2057 | 9 | { | ||
2058 | 10 | $uri:SCHEME : "http", | ||
2059 | 11 | $uri:HOST : "www.zorba-xquery.com", | ||
2060 | 12 | $uri:PATH : "/" | ||
2061 | 13 | }, | ||
2062 | 14 | { | ||
2063 | 15 | $uri:SCHEME : "http", | ||
2064 | 16 | $uri:HOST : "www.zorba-xquery.com", | ||
2065 | 17 | $uri:PATH : "/", | ||
2066 | 18 | $uri:QUERY : "abc=true" | ||
2067 | 19 | }, | ||
2068 | 20 | { | ||
2069 | 21 | $uri:SCHEME : "http", | ||
2070 | 22 | $uri:PORT : 8080, | ||
2071 | 23 | $uri:HOST : "www.zorba-xquery.com", | ||
2072 | 24 | $uri:PATH : "/", | ||
2073 | 25 | $uri:QUERY : "abc=true" | ||
2074 | 26 | }, | ||
2075 | 27 | { | ||
2076 | 28 | $uri:SCHEME : "http", | ||
2077 | 29 | $uri:PORT : 8080, | ||
2078 | 30 | $uri:HOST : "www.zorba-xquery.com", | ||
2079 | 31 | $uri:PATH : "/", | ||
2080 | 32 | $uri:USER-INFO : "user", | ||
2081 | 33 | $uri:QUERY : "abc=true" | ||
2082 | 34 | }, | ||
2083 | 35 | { | ||
2084 | 36 | $uri:SCHEME : "http", | ||
2085 | 37 | $uri:PORT : 8080, | ||
2086 | 38 | $uri:HOST : "www.zorba-xquery.com", | ||
2087 | 39 | $uri:PATH : "/path1/path2", | ||
2088 | 40 | $uri:USER-INFO : "user", | ||
2089 | 41 | $uri:QUERY : "abc=true" | ||
2090 | 42 | }, | ||
2091 | 43 | { | ||
2092 | 44 | $uri:SCHEME : "http", | ||
2093 | 45 | $uri:PORT : 8080, | ||
2094 | 46 | $uri:HOST : "www.zorba-xquery.com", | ||
2095 | 47 | $uri:PATH : "/path1/path2", | ||
2096 | 48 | $uri:USER-INFO : "user", | ||
2097 | 49 | $uri:QUERY : "abc=true&bcd=false" | ||
2098 | 50 | }, | ||
2099 | 51 | { | ||
2100 | 52 | $uri:SCHEME : "ftp", | ||
2101 | 53 | $uri:HOST : "ftp.is.co.za", | ||
2102 | 54 | $uri:PATH : "/rfc/rfc1808.txt" | ||
2103 | 55 | }, | ||
2104 | 56 | { | ||
2105 | 57 | $uri:SCHEME : "http", | ||
2106 | 58 | $uri:PORT : 123, | ||
2107 | 59 | $uri:HOST : "[2001:6f8:9000:876:cccc:bbbb::]", | ||
2108 | 60 | $uri:PATH : "/test", | ||
2109 | 61 | $uri:USER-INFO : "thomas" | ||
2110 | 62 | }, | ||
2111 | 63 | { | ||
2112 | 64 | $uri:SCHEME : "http", | ||
2113 | 65 | $uri:HOST : "a", | ||
2114 | 66 | $uri:PATH : "/b/c/g" | ||
2115 | 67 | }, | ||
2116 | 68 | { | ||
2117 | 69 | $uri:SCHEME : "http", | ||
2118 | 70 | $uri:HOST : "a", | ||
2119 | 71 | $uri:PATH : "/b/c/g/" | ||
2120 | 72 | }, | ||
2121 | 73 | { | ||
2122 | 74 | $uri:SCHEME : "http", | ||
2123 | 75 | $uri:HOST : "a", | ||
2124 | 76 | $uri:PATH : "/g" | ||
2125 | 77 | }, | ||
2126 | 78 | { | ||
2127 | 79 | $uri:SCHEME : "http", | ||
2128 | 80 | $uri:HOST : "a", | ||
2129 | 81 | $uri:PATH : "/b/c/", | ||
2130 | 82 | $uri:QUERY : "y" | ||
2131 | 83 | }, | ||
2132 | 84 | { | ||
2133 | 85 | $uri:SCHEME : "http", | ||
2134 | 86 | $uri:HOST : "a", | ||
2135 | 87 | $uri:PATH : "/b/c/g", | ||
2136 | 88 | $uri:QUERY : "y" | ||
2137 | 89 | }, | ||
2138 | 90 | { | ||
2139 | 91 | $uri:SCHEME : "http", | ||
2140 | 92 | $uri:FRAGMENT : "s", | ||
2141 | 93 | $uri:HOST : "a", | ||
2142 | 94 | $uri:PATH : "/b/c/g" | ||
2143 | 95 | }, | ||
2144 | 96 | { | ||
2145 | 97 | $uri:SCHEME : "http", | ||
2146 | 98 | $uri:FRAGMENT : "s", | ||
2147 | 99 | $uri:HOST : "a", | ||
2148 | 100 | $uri:PATH : "/b/c/g", | ||
2149 | 101 | $uri:QUERY : "y" | ||
2150 | 102 | }, | ||
2151 | 103 | { | ||
2152 | 104 | $uri:SCHEME : "http", | ||
2153 | 105 | $uri:HOST : "a", | ||
2154 | 106 | $uri:PATH : "/b/c/;x" | ||
2155 | 107 | }, | ||
2156 | 108 | { | ||
2157 | 109 | $uri:SCHEME : "http", | ||
2158 | 110 | $uri:HOST : "a", | ||
2159 | 111 | $uri:PATH : "/b/c/g;x" | ||
2160 | 112 | }, | ||
2161 | 113 | { | ||
2162 | 114 | $uri:SCHEME : "http", | ||
2163 | 115 | $uri:FRAGMENT : "s", | ||
2164 | 116 | $uri:HOST : "a", | ||
2165 | 117 | $uri:PATH : "/b/c/g;x", | ||
2166 | 118 | $uri:QUERY : "y" | ||
2167 | 119 | }, | ||
2168 | 120 | { | ||
2169 | 121 | $uri:SCHEME : "http", | ||
2170 | 122 | $uri:HOST : "a", | ||
2171 | 123 | $uri:PATH : "/b/c" | ||
2172 | 124 | }, | ||
2173 | 125 | { | ||
2174 | 126 | $uri:SCHEME : "http", | ||
2175 | 127 | $uri:HOST : "a", | ||
2176 | 128 | $uri:PATH : "/b/c/" | ||
2177 | 129 | }, | ||
2178 | 130 | { | ||
2179 | 131 | $uri:SCHEME : "http", | ||
2180 | 132 | $uri:HOST : "a", | ||
2181 | 133 | $uri:PATH : "/b" | ||
2182 | 134 | }, | ||
2183 | 135 | { | ||
2184 | 136 | $uri:SCHEME : "http", | ||
2185 | 137 | $uri:HOST : "a", | ||
2186 | 138 | $uri:PATH : "/b/" | ||
2187 | 139 | }, | ||
2188 | 140 | { | ||
2189 | 141 | $uri:SCHEME : "http", | ||
2190 | 142 | $uri:HOST : "a", | ||
2191 | 143 | $uri:PATH : "/b/g" | ||
2192 | 144 | }, | ||
2193 | 145 | { | ||
2194 | 146 | $uri:SCHEME : "http", | ||
2195 | 147 | $uri:HOST : "a", | ||
2196 | 148 | $uri:PATH : "/" | ||
2197 | 149 | }, | ||
2198 | 150 | { | ||
2199 | 151 | $uri:SCHEME : "http", | ||
2200 | 152 | $uri:HOST : "a", | ||
2201 | 153 | $uri:PATH : "/g" | ||
2202 | 154 | }, | ||
2203 | 155 | { | ||
2204 | 156 | $uri:SCHEME : "http", | ||
2205 | 157 | $uri:HOST : "a", | ||
2206 | 158 | $uri:PATH : "/b/c/g;x=1/y" | ||
2207 | 159 | }, | ||
2208 | 160 | { | ||
2209 | 161 | $uri:SCHEME : "http", | ||
2210 | 162 | $uri:HOST : "a", | ||
2211 | 163 | $uri:PATH : "/b/c/y" | ||
2212 | 164 | }, | ||
2213 | 165 | { | ||
2214 | 166 | $uri:SCHEME : "http", | ||
2215 | 167 | $uri:FRAGMENT : "s/../x", | ||
2216 | 168 | $uri:HOST : "a", | ||
2217 | 169 | $uri:PATH : "/b/c/g" | ||
2218 | 170 | }, | ||
2219 | 171 | { | ||
2220 | 172 | $uri:SCHEME : "http", | ||
2221 | 173 | $uri:HOST : "www.example.com", | ||
2222 | 174 | $uri:PATH : "/" | ||
2223 | 175 | }, | ||
2224 | 176 | { | ||
2225 | 177 | $uri:SCHEME : "http", | ||
2226 | 178 | $uri:HOST : "www.example.com", | ||
2227 | 179 | $uri:PATH : "/dir/file" | ||
2228 | 180 | }, | ||
2229 | 181 | { | ||
2230 | 182 | $uri:SCHEME : "http", | ||
2231 | 183 | $uri:HOST : "www.msb.de" | ||
2232 | 184 | }, | ||
2233 | 185 | { | ||
2234 | 186 | $uri:SCHEME : "http", | ||
2235 | 187 | $uri:HOST : "www.msb.de", | ||
2236 | 188 | $uri:PATH : "/lib/helpers" | ||
2237 | 189 | }, | ||
2238 | 190 | { | ||
2239 | 191 | $uri:SCHEME : "file", | ||
2240 | 192 | $uri:HOST : "localhost", | ||
2241 | 193 | $uri:PATH : "/Ångström/b/c" | ||
2242 | 194 | }, | ||
2243 | 195 | { | ||
2244 | 196 | $uri:SCHEME : "file", | ||
2245 | 197 | $uri:OPAQUE-PART : "opaque-uri-part", | ||
2246 | 198 | $uri:FRAGMENT : "frag" | ||
2247 | 199 | }, | ||
2248 | 200 | { | ||
2249 | 201 | $uri:SCHEME : "file", | ||
2250 | 202 | $uri:OPAQUE-PART : "text-file.txt" | ||
2251 | 203 | } | ||
2252 | 204 | ] | ||
2253 | 205 | } | ||
2254 | 206 | |||
2255 | 207 | for $index in 1 to jn:size($xml-uri-test("uri-test")) | ||
2256 | 208 | let $uri := $xml-uri-test("uri-test")($index) | ||
2257 | 209 | return ( uri:serialize($uri), " | ||
2258 | 210 | ") | ||
2259 | 211 | |||
2260 | 0 | 212 | ||
2261 | === added file 'test/rbkt/Queries/zorba/uris/serialize-uri.xq' | |||
2262 | --- test/rbkt/Queries/zorba/uris/serialize-uri.xq 1970-01-01 00:00:00 +0000 | |||
2263 | +++ test/rbkt/Queries/zorba/uris/serialize-uri.xq 2013-05-03 23:21:27 +0000 | |||
2264 | @@ -0,0 +1,9 @@ | |||
2265 | 1 | import module namespace uri = "http://www.zorba-xquery.com/modules/uri"; | ||
2266 | 2 | |||
2267 | 3 | let $xml-uri-test := fn:doc("uri-source.xml")//uri-element | ||
2268 | 4 | |||
2269 | 5 | for $uri in $xml-uri-test | ||
2270 | 6 | let $parsed-uri := uri:parse($uri) | ||
2271 | 7 | return concat(uri:serialize($parsed-uri), " | ||
2272 | 8 | ") | ||
2273 | 9 | |||
2274 | 0 | 10 | ||
2275 | === added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.spec' | |||
2276 | --- test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.spec 1970-01-01 00:00:00 +0000 | |||
2277 | +++ test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.spec 2013-05-03 23:21:27 +0000 | |||
2278 | @@ -0,0 +1,1 @@ | |||
2279 | 1 | Error: http://www.zorba-xquery.com/errors:ZURI0002 | ||
2280 | 0 | 2 | ||
2281 | === added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.xq' | |||
2282 | --- test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.xq 1970-01-01 00:00:00 +0000 | |||
2283 | +++ test/rbkt/Queries/zorba/uris/serialize-wrong-opaque-noscheme.xq 2013-05-03 23:21:27 +0000 | |||
2284 | @@ -0,0 +1,8 @@ | |||
2285 | 1 | import module namespace uri = "http://www.zorba-xquery.com/modules/uri"; | ||
2286 | 2 | |||
2287 | 3 | let $wrong-opaque-noscheme-json := | ||
2288 | 4 | { | ||
2289 | 5 | "opaque-part" : "myfile.xml" | ||
2290 | 6 | } | ||
2291 | 7 | |||
2292 | 8 | return uri:serialize($wrong-opaque-noscheme-json) | ||
2293 | 0 | 9 | ||
2294 | === added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.spec' | |||
2295 | --- test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.spec 1970-01-01 00:00:00 +0000 | |||
2296 | +++ test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.spec 2013-05-03 23:21:27 +0000 | |||
2297 | @@ -0,0 +1,1 @@ | |||
2298 | 1 | Error: http://www.zorba-xquery.com/errors:ZURI0001 | ||
2299 | 0 | 2 | ||
2300 | === added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.xq' | |||
2301 | --- test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.xq 1970-01-01 00:00:00 +0000 | |||
2302 | +++ test/rbkt/Queries/zorba/uris/serialize-wrong-opaque.xq 2013-05-03 23:21:27 +0000 | |||
2303 | @@ -0,0 +1,10 @@ | |||
2304 | 1 | import module namespace uri = "http://www.zorba-xquery.com/modules/uri"; | ||
2305 | 2 | |||
2306 | 3 | let $wrong-opaque-json := | ||
2307 | 4 | { | ||
2308 | 5 | "scheme" : "http", | ||
2309 | 6 | "opaque-part" : "myfile.xml", | ||
2310 | 7 | "path" : "d:/a/b/c" | ||
2311 | 8 | } | ||
2312 | 9 | |||
2313 | 10 | return uri:serialize($wrong-opaque-json) | ||
2314 | 0 | 11 | ||
2315 | === added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-path1.spec' | |||
2316 | --- test/rbkt/Queries/zorba/uris/serialize-wrong-path1.spec 1970-01-01 00:00:00 +0000 | |||
2317 | +++ test/rbkt/Queries/zorba/uris/serialize-wrong-path1.spec 2013-05-03 23:21:27 +0000 | |||
2318 | @@ -0,0 +1,1 @@ | |||
2319 | 1 | Error: http://www.zorba-xquery.com/errors:ZURI0003 | ||
2320 | 0 | 2 | ||
2321 | === added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-path1.xq' | |||
2322 | --- test/rbkt/Queries/zorba/uris/serialize-wrong-path1.xq 1970-01-01 00:00:00 +0000 | |||
2323 | +++ test/rbkt/Queries/zorba/uris/serialize-wrong-path1.xq 2013-05-03 23:21:27 +0000 | |||
2324 | @@ -0,0 +1,9 @@ | |||
2325 | 1 | import module namespace uri = "http://www.zorba-xquery.com/modules/uri"; | ||
2326 | 2 | |||
2327 | 3 | let $wrong-path-json := | ||
2328 | 4 | { | ||
2329 | 5 | "scheme" : "file", | ||
2330 | 6 | "path" : "d:/a/b/c" | ||
2331 | 7 | } | ||
2332 | 8 | |||
2333 | 9 | return uri:serialize($wrong-path-json) | ||
2334 | 0 | 10 | ||
2335 | === added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-path2.spec' | |||
2336 | --- test/rbkt/Queries/zorba/uris/serialize-wrong-path2.spec 1970-01-01 00:00:00 +0000 | |||
2337 | +++ test/rbkt/Queries/zorba/uris/serialize-wrong-path2.spec 2013-05-03 23:21:27 +0000 | |||
2338 | @@ -0,0 +1,1 @@ | |||
2339 | 1 | Error: http://www.zorba-xquery.com/errors:ZURI0003 | ||
2340 | 0 | 2 | ||
2341 | === added file 'test/rbkt/Queries/zorba/uris/serialize-wrong-path2.xq' | |||
2342 | --- test/rbkt/Queries/zorba/uris/serialize-wrong-path2.xq 1970-01-01 00:00:00 +0000 | |||
2343 | +++ test/rbkt/Queries/zorba/uris/serialize-wrong-path2.xq 2013-05-03 23:21:27 +0000 | |||
2344 | @@ -0,0 +1,10 @@ | |||
2345 | 1 | import module namespace uri = "http://www.zorba-xquery.com/modules/uri"; | ||
2346 | 2 | |||
2347 | 3 | let $wrong-path-json := | ||
2348 | 4 | { | ||
2349 | 5 | "scheme" : "file", | ||
2350 | 6 | "host" : "localhost", | ||
2351 | 7 | "path" : "d:/a/b/c" | ||
2352 | 8 | } | ||
2353 | 9 | |||
2354 | 10 | return uri:serialize($wrong-path-json) | ||
2355 | 0 | 11 | ||
2356 | === added file 'test/rbkt/Queries/zorba/uris/uri-source.xml' | |||
2357 | --- test/rbkt/Queries/zorba/uris/uri-source.xml 1970-01-01 00:00:00 +0000 | |||
2358 | +++ test/rbkt/Queries/zorba/uris/uri-source.xml 2013-05-03 23:21:27 +0000 | |||
2359 | @@ -0,0 +1,46 @@ | |||
2360 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2361 | 2 | <uri-test> | ||
2362 | 3 | <uri-element>http:///</uri-element> | ||
2363 | 4 | <uri-element>http://www.zorba-xquery.com/</uri-element> | ||
2364 | 5 | <uri-element>http://www.zorba-xquery.com/?abc=true</uri-element> | ||
2365 | 6 | <uri-element>http://www.zorba-xquery.com:8080/?abc=true</uri-element> | ||
2366 | 7 | <uri-element>http://user@www.zorba-xquery.com:8080/?abc=true</uri-element> | ||
2367 | 8 | <uri-element>http://user@www.zorba-xquery.com:8080/path1/path2?abc=true</uri-element> | ||
2368 | 9 | <uri-element>http://user@www.zorba-xquery.com:8080/path1/path2?abc=true&bcd=false#fragment</uri-element> | ||
2369 | 10 | <uri-element>ftp://ftp.is.co.za/rfc/rfc1808.txt</uri-element> | ||
2370 | 11 | <uri-element>http://thomas@[2001:6f8:9000:876:cccc:bbbb::]:123/test</uri-element> | ||
2371 | 12 | <uri-element>http://a/b/c/g</uri-element> | ||
2372 | 13 | <uri-element>http://a/b/c/g</uri-element> | ||
2373 | 14 | <uri-element>http://a/b/c/g/</uri-element> | ||
2374 | 15 | <uri-element>http://a/g</uri-element> | ||
2375 | 16 | <uri-element>http://a/b/c/?y</uri-element> | ||
2376 | 17 | <uri-element>http://a/b/c/g?y</uri-element> | ||
2377 | 18 | <uri-element>http://a/b/c/g#s</uri-element> | ||
2378 | 19 | <uri-element>http://a/b/c/g?y#s</uri-element> | ||
2379 | 20 | <uri-element>http://a/b/c/;x</uri-element> | ||
2380 | 21 | <uri-element>http://a/b/c/g;x</uri-element> | ||
2381 | 22 | <uri-element>http://a/b/c/g;x?y#s</uri-element> | ||
2382 | 23 | <uri-element>http://a/b/c/</uri-element> | ||
2383 | 24 | <uri-element>http://a/b/c/</uri-element> | ||
2384 | 25 | <uri-element>http://a/b/</uri-element> | ||
2385 | 26 | <uri-element>http://a/b/</uri-element> | ||
2386 | 27 | <uri-element>http://a/b/g</uri-element> | ||
2387 | 28 | <uri-element>http://a/</uri-element> | ||
2388 | 29 | <uri-element>http://a/</uri-element> | ||
2389 | 30 | <uri-element>http://a/g</uri-element> | ||
2390 | 31 | <uri-element>http://a/b/c/g;x=1/y</uri-element> | ||
2391 | 32 | <uri-element>http://a/b/c/y</uri-element> | ||
2392 | 33 | <uri-element>http://a/b/c/g#s/../x</uri-element> | ||
2393 | 34 | <uri-element>http://www.example.com/</uri-element> | ||
2394 | 35 | <uri-element>http://www.example.com/dir/file</uri-element> | ||
2395 | 36 | <uri-element>http://www.msb.de</uri-element> | ||
2396 | 37 | <uri-element>http://www.msb.de/lib/helpers</uri-element> | ||
2397 | 38 | <uri-element>file:///d:/a/b/c</uri-element> | ||
2398 | 39 | <uri-element>file://localhost/d:/a/b/c</uri-element> | ||
2399 | 40 | <uri-element>file://localhost/Ångström/b/c</uri-element> | ||
2400 | 41 | <uri-element>file:opaque-uri-part#frag</uri-element> | ||
2401 | 42 | <uri-element>file:text-file.txt</uri-element> | ||
2402 | 43 | <uri-element>file:bar?</uri-element> | ||
2403 | 44 | <uri-element>file:bar?#frag</uri-element> | ||
2404 | 45 | <uri-element>http://foo.com/bc?</uri-element> | ||
2405 | 46 | </uri-test> |
- Why is there a schema imported in uri.xq? I don't think it's needed anymore. modules/ CMakeLists. txt?
- The documentation should say what types of errors the function can raise.
- It would be nice to have constants for the names of the fields in the objects (e.g. scheme, opaque-part)
- Why does the change comment out all language bindings in swig/CMakeLists.txt and test/rbkt/