Skip to content

Commit af2b066

Browse files
committed
libxml-2.9.2 compatibility
1 parent 2ac3187 commit af2b066

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ext/libxml/libxml.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,21 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char
306306
(xmlStrncmp(BAD_CAST uri->scheme, BAD_CAST "file", 4) == 0))) {
307307
resolved_path = xmlURIUnescapeString(filename, 0, NULL);
308308
isescaped = 1;
309+
#if LIBXML_VERSION >= 20902 && defined(PHP_WIN32)
310+
/* Libxml 2.9.2 prefixes local paths with file:/ instead of file://,
311+
thus the php stream wrapper will fail on a valid case. For this
312+
reason the prefix is rather better cut off. */
313+
{
314+
size_t pre_len = sizeof("file:/") - 1;
315+
316+
if (strncasecmp(resolved_path, "file:/", pre_len) == 0
317+
&& '/' != resolved_path[pre_len]) {
318+
xmlChar *tmp = xmlStrdup(resolved_path + pre_len);
319+
xmlFree(resolved_path);
320+
resolved_path = tmp;
321+
}
322+
}
323+
#endif
309324
} else {
310325
resolved_path = (char *)filename;
311326
}

0 commit comments

Comments
 (0)