Переглянути джерело

[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 15 роки тому
джерело
коміт
3fe6bede74
1 змінених файлів з 6 додано та 2 видалено
  1. 6
    2
      src/core/uri.c

+ 6
- 2
src/core/uri.c Переглянути файл

@@ -92,8 +92,12 @@ struct uri * parse_uri ( const char *uri_string ) {
92 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 101
 		/* Absolute URI: identify hierarchical/opaque */
98 102
 		uri->scheme = raw;
99 103
 		*(tmp++) = '\0';

Завантаження…
Відмінити
Зберегти