]>
Commit | Line | Data |
---|---|---|
3f814cc5 JB |
1 | --- libxml2-2.10.0/xmlIO.c.orig 2022-08-18 16:29:32.843322082 +0200 |
2 | +++ libxml2-2.10.0/xmlIO.c 2022-08-18 16:32:12.985787850 +0200 | |
3 | @@ -1115,8 +1115,33 @@ xmlGzfileOpen_real (const char *filename | |
7f111c10 MM |
4 | |
5 | if (path == NULL) | |
6 | return(NULL); | |
7 | - if (!xmlCheckFilename(path)) | |
8 | - return(NULL); | |
7f111c10 | 9 | + if (!xmlCheckFilename(path)) { |
3f814cc5 | 10 | + /* If we cannot open `foo.xml', we try `foo.xml.gz'. However we i |
7f111c10 | 11 | + * append .gz only if filename doesn't alreay end with .gz. */ |
3f814cc5 JB |
12 | + if (strlen(path) < 3 || strcmp(path + strlen(path) - 3, ".gz") != 0) { |
13 | + char *gz_filename = xmlMalloc(strlen(path) + 4); | |
7f111c10 MM |
14 | + |
15 | + if (gz_filename == NULL) { | |
16 | + xmlGenericError(xmlGenericErrorContext, | |
17 | + "xmlGzfileOpen: %s\n", | |
18 | + "Failure allocating buffer for filename."); | |
19 | + return NULL; | |
3f814cc5 | 20 | + } |
7f111c10 | 21 | + |
3f814cc5 JB |
22 | + strcpy(gz_filename, path); |
23 | + strcat(gz_filename, ".gz"); | |
24 | + | |
25 | + fd = NULL; | |
26 | + | |
27 | + if (xmlCheckFilename(gz_filename)) | |
7f111c10 | 28 | + fd = gzopen(gz_filename, "rb"); |
3f814cc5 JB |
29 | + |
30 | + xmlFree(gz_filename); | |
7f111c10 | 31 | + |
3f814cc5 JB |
32 | + return((void *) fd); |
33 | + } else | |
7f111c10 | 34 | + return NULL; |
7f111c10 MM |
35 | + } |
36 | ||
3f814cc5 | 37 | #if defined(_WIN32) |
eadb354e | 38 | fd = xmlWrapGzOpenUtf8(path, "rb"); |