On Oct 11, 2007 9:43 PM, Henry Jen <[EMAIL PROTECTED]> wrote:
>
> On 10/5/07, Paul Querna <[EMAIL PROTECTED]> wrote:
> > William A. Rowe, Jr. wrote:
> > > Henry Jen wrote:
> > >> Hi,
> > >>
> > >> ApacheCon US is a month away, and this year I get to attend the event,
> > >> yeah!
> > >>
> > >> Wondering if there is going to be a hackathon or some sort of activity
> > >> for APR/APR-util developers to get together?
> > >
> > > I would sure like to see it! Since Tuesday gets busy with several special
> > > events, who's up for trying to be there on Monday?
> >
> > I'll be around... I would like to hammer out the APR Events stuff that
> > davi commited to a branch, and merge it into trunk:
> > http://svn.apache.org/repos/asf/apr/apr/branches/evenset/
> >
> > Anything else people would like to see?
> >
>
> I will be around as well.
> What I would like to discuss is a few changes to apr_uri to be more
> accurate to RFC 3986 compliant, particular for the path support.
>
> Per RFC 3986,
>
> URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
>
> hier-part = "//" authority path-abempty
> / path-absolute
> / path-rootless
> / path-empty
>
> I am expecting file:./tmp/tnt.pdf to get a scheme "file" and path
> "./tmp/tnt.pdf", but I got:
>
> [EMAIL PROTECTED]:~/prj/test/c$ ./apr_uri_test file:./tmp/tnt.pdf
> Parsing file:./tmp/tnt.pdf ------------
> scheme: n/a
> hostinfo: n/a
> user: n/a
> password: n/a
> hostname: n/a
> port_str: n/a
> path: file:./tmp/tnt.pdf
> query: n/a
> fragment: n/a
> hostent: 0
> port: 0
> is_initialized: 1
> dns_looked_up: 0
> dns_resolved: 0
>
Index: uri/apr_uri.c
===================================================================
--- uri/apr_uri.c (revision 582411)
+++ uri/apr_uri.c (working copy)
@@ -92,7 +92,13 @@
unsigned flags)
{
char *ret = "";
+ char *scheme = NULL;
+ if (uptr->scheme) {
+ scheme = apr_pstrcat(p, uptr->scheme, ":", NULL);
+ }
+
+
/* If suppressing the site part, omit both user name & scheme://hostname */
if (!(flags & APR_URI_UNP_OMITSITEPART)) {
@@ -129,29 +135,15 @@
uptr->port == 0 ||
uptr->port == apr_uri_port_of_scheme(uptr->scheme));
- if (uptr->scheme) {
- ret = apr_pstrcat(p,
- uptr->scheme, "://", ret,
- lbrk, uptr->hostname, rbrk,
- is_default_port ? "" : ":",
- is_default_port ? "" : uptr->port_str,
- NULL);
- }
- else {
- /* A violation of RFC2396, but it is clear from section 3.2
- * that the : belongs above to the scheme, while // belongs
- * to the authority, so include the authority prefix while
- * omitting the "scheme:" that the user neglected to pass us.
- */
- ret = apr_pstrcat(p,
- "//", ret, lbrk, uptr->hostname, rbrk,
- is_default_port ? "" : ":",
- is_default_port ? "" : uptr->port_str,
- NULL);
- }
+ ret = apr_pstrcat(p, "//", ret, lbrk, uptr->hostname, rbrk,
+ is_default_port ? "" : ":",
+ is_default_port ? "" : uptr->port_str,
+ NULL);
}
}
+ ret = apr_pstrcat(p, scheme ? scheme : "", ret, NULL);
+
/* Should we suppress all path info? */
if (!(flags & APR_URI_UNP_OMITPATHINFO)) {
/* Append path, query and fragment strings: */
@@ -324,12 +316,17 @@
while ((uri_delims[*(unsigned char *)s] & NOTEND_SCHEME) == 0) {
++s;
}
- /* scheme must be non-empty and followed by :// */
- if (s == uri || s[0] != ':' || s[1] != '/' || s[2] != '/') {
+ /* scheme must be non-empty and followed by : */
+ if (s == uri || s[0] != ':') {
goto deal_with_path; /* backwards predicted taken! */
}
uptr->scheme = apr_pstrmemdup(p, uri, s - uri);
+ if (s[1] != '/' || s[2] != '/') {
+ uri = s + 1;
+ goto deal_with_path;
+ }
+
s += 3;
deal_with_authority:
Index: test/testuri.c
===================================================================
--- test/testuri.c (revision 582411)
+++ test/testuri.c (working copy)
@@ -95,6 +95,30 @@
"//www.apache.org/",
0, NULL, "www.apache.org", NULL, NULL, "www.apache.org", NULL, "/", NULL, NULL, 0
},
+ {
+ "file:image.jpg",
+ 0, "file", NULL, NULL, NULL, NULL, NULL, "image.jpg", NULL, NULL, 0
+ },
+ {
+ "file:/image.jpg",
+ 0, "file", NULL, NULL, NULL, NULL, NULL, "/image.jpg", NULL, NULL, 0
+ },
+ {
+ "file:///image.jpg",
+ 0, "file", "", NULL, NULL, "", NULL, "/image.jpg", NULL, NULL, 0
+ },
+ {
+ "file:///tmp/photos/image.jpg",
+ 0, "file", "", NULL, NULL, "", NULL, "/tmp/photos/image.jpg", NULL, NULL, 0
+ },
+ {
+ "file:./image.jpg",
+ 0, "file", NULL, NULL, NULL, NULL, NULL, "./image.jpg", NULL, NULL, 0
+ },
+ {
+ "file:../photos/image.jpg",
+ 0, "file", NULL, NULL, NULL, NULL, NULL, "../photos/image.jpg", NULL, NULL, 0
+ },
};
struct uph_test {