You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by wr...@apache.org on 2003/03/03 19:31:58 UTC
cvs commit: apr-util/uri apr_uri.c
wrowe 2003/03/03 10:31:58
Modified: uri apr_uri.c
Log:
As identified by Stas, we were segfaulting when ->scheme was omitted to
apr_uri_unparse. Substitute the behavior of dropping "scheme:" from the
returned string if the user neglects to pass us a scheme.
Also optimize the default port-of-scheme code to drop out quickly
for a NULL scheme rather than comparing NULL to every scheme.
Solves mod_perl's Apache::compat segfault - they will still need to inject
"http" for their scheme if one is not provided to remain compatible with
Apache 1.3's behavior.
Revision Changes Path
1.17 +20 -5 apr-util/uri/apr_uri.c
Index: apr_uri.c
===================================================================
RCS file: /home/cvs/apr-util/uri/apr_uri.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- apr_uri.c 1 Jan 2003 00:02:22 -0000 1.16
+++ apr_uri.c 3 Mar 2003 18:31:58 -0000 1.17
@@ -112,12 +112,13 @@
{
schemes_t *scheme;
- for (scheme = schemes; scheme->name != NULL; ++scheme) {
- if (strcasecmp(scheme_str, scheme->name) == 0) {
- return scheme->default_port;
+ if (scheme_str) {
+ for (scheme = schemes; scheme->name != NULL; ++scheme) {
+ if (strcasecmp(scheme_str, scheme->name) == 0) {
+ return scheme->default_port;
+ }
}
}
-
return 0;
}
@@ -172,12 +173,26 @@
uptr->port == 0 ||
uptr->port == apr_uri_port_of_scheme(uptr->scheme));
- ret = apr_pstrcat(p,
+ 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);
+ }
}
}