Browse Source

[uri] Avoid interpreting DOS-style path names as opaque URIs

A DOS-style full path name such as "C:\Program Files\tftpboot\nbp.0"
satisfies the syntax requirements for a URI with a scheme of "C" and
an opaque portion of "\Program Files\tftpboot\nbp.0".

Add a check in parse_uri() to ignore schemes that are apparently only
a single character long; this avoids interpreting DOS-style paths in
this way, and shouldn't affect any practical URI scheme.
tags/v0.9.6
Michael Brown 16 years ago
parent
commit
3fe6bede74
1 changed files with 6 additions and 2 deletions
  1. 6
    2
      src/core/uri.c

+ 6
- 2
src/core/uri.c View File

92
 		uri->fragment = tmp;
92
 		uri->fragment = tmp;
93
 	}
93
 	}
94
 
94
 
95
-	/* Identify absolute/relative URI */
96
-	if ( ( tmp = strchr ( raw, ':' ) ) ) {
95
+	/* Identify absolute/relative URI.  We ignore schemes that are
96
+	 * apparently only a single character long, since otherwise we
97
+	 * misinterpret a DOS-style path name ("C:\path\to\file") as a
98
+	 * URI with scheme="C",opaque="\path\to\file".
99
+	 */
100
+	if ( ( tmp = strchr ( raw, ':' ) ) && ( tmp > ( raw + 1 ) ) ) {
97
 		/* Absolute URI: identify hierarchical/opaque */
101
 		/* Absolute URI: identify hierarchical/opaque */
98
 		uri->scheme = raw;
102
 		uri->scheme = raw;
99
 		*(tmp++) = '\0';
103
 		*(tmp++) = '\0';

Loading…
Cancel
Save