|
79 | 79 | #define URI_HASH_EMPTY 0xD943A04E |
80 | 80 | #define URI_HASH_XML 0xF0451F02 |
81 | 81 |
|
| 82 | +#ifndef STDIN_FILENO |
| 83 | + #define STDIN_FILENO 0 |
| 84 | +#endif |
| 85 | + |
82 | 86 | struct _xmlStartTag { |
83 | 87 | const xmlChar *prefix; |
84 | 88 | const xmlChar *URI; |
@@ -12739,7 +12743,10 @@ xmlSAXParseFileWithData(xmlSAXHandlerPtr sax, const char *filename, |
12739 | 12743 | ctxt->recovery = 1; |
12740 | 12744 | } |
12741 | 12745 |
|
12742 | | - input = xmlNewInputURL(ctxt, filename, NULL, NULL, 0); |
| 12746 | + if ((filename != NULL) && (filename[0] == '-') && (filename[1] == 0)) |
| 12747 | + input = xmlNewInputFd(ctxt, filename, STDIN_FILENO, NULL, 0); |
| 12748 | + else |
| 12749 | + input = xmlNewInputURL(ctxt, filename, NULL, NULL, 0); |
12743 | 12750 |
|
12744 | 12751 | ret = xmlCtxtParseDocument(ctxt, input); |
12745 | 12752 |
|
@@ -13761,7 +13768,15 @@ xmlReadFile(const char *filename, const char *encoding, int options) |
13761 | 13768 |
|
13762 | 13769 | xmlCtxtUseOptions(ctxt, options); |
13763 | 13770 |
|
13764 | | - input = xmlNewInputURL(ctxt, filename, NULL, encoding, 0); |
| 13771 | + /* |
| 13772 | + * Backward compatibility for users of command line utilities like |
| 13773 | + * xmlstarlet expecting "-" to mean stdin. This is dangerous and |
| 13774 | + * should be removed at some point. |
| 13775 | + */ |
| 13776 | + if ((filename != NULL) && (filename[0] == '-') && (filename[1] == 0)) |
| 13777 | + input = xmlNewInputFd(ctxt, filename, STDIN_FILENO, encoding, 0); |
| 13778 | + else |
| 13779 | + input = xmlNewInputURL(ctxt, filename, NULL, encoding, 0); |
13765 | 13780 |
|
13766 | 13781 | doc = xmlCtxtParseDocument(ctxt, input); |
13767 | 13782 |
|
|
0 commit comments