| 469 | } |
| 470 | |
| 471 | static int |
| 472 | xmlConvertUriToPath(const char *uri, char **out) { |
| 473 | const char *escaped; |
| 474 | char *unescaped; |
| 475 | |
| 476 | *out = NULL; |
| 477 | |
| 478 | if (!xmlStrncasecmp(BAD_CAST uri, BAD_CAST "file://localhost/", 17)) { |
| 479 | escaped = &uri[16]; |
| 480 | } else if (!xmlStrncasecmp(BAD_CAST uri, BAD_CAST "file:///", 8)) { |
| 481 | escaped = &uri[7]; |
| 482 | } else if (!xmlStrncasecmp(BAD_CAST uri, BAD_CAST "file:/", 6)) { |
| 483 | /* lots of generators seems to lazy to read RFC 1738 */ |
| 484 | escaped = &uri[5]; |
| 485 | } else { |
| 486 | return(1); |
| 487 | } |
| 488 | |
| 489 | #ifdef _WIN32 |
| 490 | /* Ignore slash like in file:///C:/file.txt */ |
| 491 | escaped += 1; |
| 492 | #endif |
| 493 | |
| 494 | unescaped = xmlURIUnescapeString(escaped, 0, NULL); |
| 495 | if (unescaped == NULL) |
| 496 | return(-1); |
| 497 | |
| 498 | *out = unescaped; |
| 499 | return(0); |
| 500 | } |
| 501 | |
| 502 | /** |
| 503 | * xmlFdOpen: |
no test coverage detected