@@ -2397,21 +2397,19 @@ xmlParseUriOrPath(const char *str, xmlURIPtr *out, int *drive) {
23972397 if (xmlIsAbsolutePath (BAD_CAST buf )) {
23982398#if defined(_WIN32 ) || defined(__CYGWIN__ )
23992399 const char * server = NULL ;
2400+ int isFileScheme = 0 ;
24002401#endif
24012402
2402- uri -> scheme = (char * ) xmlStrdup (BAD_CAST "file" );
2403- if (uri -> scheme == NULL ) {
2404- ret = -1 ;
2405- goto done ;
2406- }
2407-
24082403#if defined(_WIN32 ) || defined(__CYGWIN__ )
24092404 if (strncmp (buf , "//?/UNC/" , 8 ) == 0 ) {
24102405 server = buf + 8 ;
2406+ isFileScheme = 1 ;
24112407 } else if (strncmp (buf , "//?/" , 4 ) == 0 ) {
24122408 path = buf + 3 ;
2409+ isFileScheme = 1 ;
24132410 } else if (strncmp (buf , "//" , 2 ) == 0 ) {
24142411 server = buf + 2 ;
2412+ isFileScheme = 1 ;
24152413 }
24162414
24172415 if (server != NULL ) {
@@ -2433,12 +2431,22 @@ xmlParseUriOrPath(const char *str, xmlURIPtr *out, int *drive) {
24332431
24342432 if ((((path [0 ] >= 'A' ) && (path [0 ] <= 'Z' )) ||
24352433 ((path [0 ] >= 'a' ) && (path [0 ] <= 'z' ))) &&
2436- (path [1 ] == ':' ))
2434+ (path [1 ] == ':' )) {
24372435 prependSlash = 1 ;
2438- #endif
2436+ isFileScheme = 1 ;
2437+ }
24392438
2440- if (uri -> server == NULL )
2441- uri -> port = PORT_EMPTY_SERVER ;
2439+ if (isFileScheme ) {
2440+ uri -> scheme = xmlMemStrdup ("file" );
2441+ if (uri -> scheme == NULL ) {
2442+ ret = -1 ;
2443+ goto done ;
2444+ }
2445+
2446+ if (uri -> server == NULL )
2447+ uri -> port = PORT_EMPTY_SERVER ;
2448+ }
2449+ #endif
24422450 }
24432451
24442452 pathSize = strlen (path );
@@ -2591,15 +2599,21 @@ xmlBuildRelativeURISafe(const xmlChar * URI, const xmlChar * base,
25912599 remove_path = 1 ;
25922600 }
25932601
2602+ bptr = (xmlChar * ) bas -> path ;
2603+ rptr = (xmlChar * ) ref -> path ;
2604+
2605+ /*
2606+ * Return URI if URI and base aren't both absolute or relative.
2607+ */
2608+ if ((bptr [0 ] == '/' ) != (rptr [0 ] == '/' ))
2609+ goto done ;
2610+
25942611 /*
25952612 * At this point we can compare the two paths
25962613 */
25972614 {
25982615 int pos = 0 ;
25992616
2600- bptr = (xmlChar * ) bas -> path ;
2601- rptr = (xmlChar * ) ref -> path ;
2602-
26032617 /*
26042618 * Next we compare the two strings and find where they first differ
26052619 */
0 commit comments