Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 2450 invoked from network); 9 Dec 2007 16:04:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Dec 2007 16:04:48 -0000 Received: (qmail 45523 invoked by uid 500); 9 Dec 2007 16:04:36 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 45508 invoked by uid 500); 9 Dec 2007 16:04:36 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 45497 invoked by uid 99); 9 Dec 2007 16:04:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Dec 2007 08:04:36 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Dec 2007 16:04:38 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C13BF1A9832; Sun, 9 Dec 2007 08:04:16 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r602690 - in /apr/apr-util/branches/1.2.x: CHANGES test/testuri.c uri/apr_uri.c Date: Sun, 09 Dec 2007 16:04:16 -0000 To: commits@apr.apache.org From: rpluem@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071209160416.C13BF1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rpluem Date: Sun Dec 9 08:04:15 2007 New Revision: 602690 URL: http://svn.apache.org/viewvc?rev=602690&view=rev Log: Merge r594624 from trunk: Add better scheme/host parsing to apr_uri. Submitted by: Henry Jen Reviewed by: rpluem Modified: apr/apr-util/branches/1.2.x/CHANGES apr/apr-util/branches/1.2.x/test/testuri.c apr/apr-util/branches/1.2.x/uri/apr_uri.c Modified: apr/apr-util/branches/1.2.x/CHANGES URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.2.x/CHANGES?rev=602690&r1=602689&r2=602690&view=diff ============================================================================== --- apr/apr-util/branches/1.2.x/CHANGES [utf-8] (original) +++ apr/apr-util/branches/1.2.x/CHANGES [utf-8] Sun Dec 9 08:04:15 2007 @@ -2,6 +2,9 @@ Changes with APR-util 1.2.13 + *) Add better scheme/host parsing to apr_uri. + [Henry Jen ] + *) Fix the make test target in the spec file. [Graham Leggett] Changes with APR-util 1.2.12 Modified: apr/apr-util/branches/1.2.x/test/testuri.c URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.2.x/test/testuri.c?rev=602690&r1=602689&r2=602690&view=diff ============================================================================== --- apr/apr-util/branches/1.2.x/test/testuri.c (original) +++ apr/apr-util/branches/1.2.x/test/testuri.c Sun Dec 9 08:04:15 2007 @@ -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 { Modified: apr/apr-util/branches/1.2.x/uri/apr_uri.c URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.2.x/uri/apr_uri.c?rev=602690&r1=602689&r2=602690&view=diff ============================================================================== --- apr/apr-util/branches/1.2.x/uri/apr_uri.c (original) +++ apr/apr-util/branches/1.2.x/uri/apr_uri.c Sun Dec 9 08:04:15 2007 @@ -92,6 +92,12 @@ 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: