diff options
Diffstat (limited to 'xmlwf')
| -rw-r--r-- | xmlwf/Makefile.in | 10 | ||||
| -rw-r--r-- | xmlwf/readfilemap.c | 21 | ||||
| -rw-r--r-- | xmlwf/xmlfile.c | 16 | ||||
| -rw-r--r-- | xmlwf/xmlfile.h | 4 | ||||
| -rw-r--r-- | xmlwf/xmlwf.c | 156 | ||||
| -rwxr-xr-x | xmlwf/xmlwf_helpgen.py | 31 |
6 files changed, 152 insertions, 86 deletions
diff --git a/xmlwf/Makefile.in b/xmlwf/Makefile.in index 9179e1cb1119..a8a84dc4e6de 100644 --- a/xmlwf/Makefile.in +++ b/xmlwf/Makefile.in @@ -134,6 +134,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/conftools/ax-append-compile-flags.m4 \ $(top_srcdir)/conftools/ax-append-link-flags.m4 \ $(top_srcdir)/conftools/expatcfg-compiler-supports-visibility.m4 \ + $(top_srcdir)/conftools/ax-cxx-compile-stdcxx.m4 \ + $(top_srcdir)/conftools/ax-cxx-compile-stdcxx-11.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) @@ -267,6 +269,7 @@ FGREP = @FGREP@ FILECMD = @FILECMD@ FILEMAP = @FILEMAP@ GREP = @GREP@ +HAVE_CXX11 = @HAVE_CXX11@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -286,6 +289,7 @@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ @@ -392,7 +396,7 @@ all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ @@ -416,9 +420,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(top_srcdir)/configure: $(am__configure_deps) +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) diff --git a/xmlwf/readfilemap.c b/xmlwf/readfilemap.c index 59121f5b4dfe..2cb53feef8d5 100644 --- a/xmlwf/readfilemap.c +++ b/xmlwf/readfilemap.c @@ -13,6 +13,7 @@ Copyright (c) 2016-2017 Sebastian Pipping <sebastian@pipping.org> Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk> Copyright (c) 2017 Franek Korta <fkorta@gmail.com> + Copyright (c) 2022 Sean McBride <sean@rogue-research.com> Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -50,14 +51,14 @@ #if defined(_MSC_VER) # include <io.h> /* https://msdn.microsoft.com/en-us/library/wyssk1bs(v=vs.100).aspx */ -# define _EXPAT_read _read -# define _EXPAT_read_count_t int -# define _EXPAT_read_req_t unsigned int +# define EXPAT_read _read +# define EXPAT_read_count_t int +# define EXPAT_read_req_t unsigned int #else /* POSIX */ /* http://pubs.opengroup.org/onlinepubs/009695399/functions/read.html */ -# define _EXPAT_read read -# define _EXPAT_read_count_t ssize_t -# define _EXPAT_read_req_t size_t +# define EXPAT_read read +# define EXPAT_read_count_t ssize_t +# define EXPAT_read_req_t size_t #endif #ifndef S_ISREG @@ -67,7 +68,7 @@ # ifndef S_IFMT # define S_IFMT _S_IFMT # endif -# define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) +# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #endif /* not S_ISREG */ #ifndef O_BINARY @@ -87,7 +88,7 @@ filemap(const tchar *name, void *arg) { size_t nbytes; int fd; - _EXPAT_read_count_t n; + EXPAT_read_count_t n; struct stat sb; void *p; @@ -125,14 +126,14 @@ filemap(const tchar *name, close(fd); return 0; } - n = _EXPAT_read(fd, p, (_EXPAT_read_req_t)nbytes); + n = EXPAT_read(fd, p, (EXPAT_read_req_t)nbytes); if (n < 0) { tperror(name); free(p); close(fd); return 0; } - if (n != (_EXPAT_read_count_t)nbytes) { + if (n != (EXPAT_read_count_t)nbytes) { ftprintf(stderr, T("%s: read unexpected number of bytes\n"), name); free(p); close(fd); diff --git a/xmlwf/xmlfile.c b/xmlwf/xmlfile.c index e3521676c5b9..0598b86b5fb7 100644 --- a/xmlwf/xmlfile.c +++ b/xmlwf/xmlfile.c @@ -11,10 +11,10 @@ Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> Copyright (c) 2004-2006 Karl Waclawek <karl@waclawek.net> Copyright (c) 2005-2007 Steven Solie <steven@solie.ca> - Copyright (c) 2016-2021 Sebastian Pipping <sebastian@pipping.org> + Copyright (c) 2016-2023 Sebastian Pipping <sebastian@pipping.org> Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk> Copyright (c) 2019 David Loffredo <loffredo@steptools.com> - Copyright (c) 2021 Dong-hee Na <donghee.na@python.org> + Copyright (c) 2021 Donghee Na <donghee.na@python.org> Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -37,7 +37,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include <expat_config.h> +#include "expat_config.h" #include <stdio.h> #include <stdlib.h> @@ -71,11 +71,7 @@ # endif #endif -#ifdef _DEBUG -# define READ_SIZE 16 -#else -# define READ_SIZE (1024 * 8) -#endif +int g_read_size_bytes = 1024 * 8; typedef struct { XML_Parser parser; @@ -195,7 +191,7 @@ processStream(const XML_Char *filename, XML_Parser parser) { } for (;;) { int nread; - char *buf = (char *)XML_GetBuffer(parser, READ_SIZE); + char *buf = (char *)XML_GetBuffer(parser, g_read_size_bytes); if (! buf) { if (filename != NULL) close(fd); @@ -203,7 +199,7 @@ processStream(const XML_Char *filename, XML_Parser parser) { filename != NULL ? filename : T("xmlwf")); return 0; } - nread = read(fd, buf, READ_SIZE); + nread = read(fd, buf, g_read_size_bytes); if (nread < 0) { tperror(filename != NULL ? filename : T("STDIN")); if (filename != NULL) diff --git a/xmlwf/xmlfile.h b/xmlwf/xmlfile.h index d75dda222792..579201ccf498 100644 --- a/xmlwf/xmlfile.h +++ b/xmlwf/xmlfile.h @@ -10,7 +10,7 @@ Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net> Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> Copyright (c) 2005 Karl Waclawek <karl@waclawek.net> - Copyright (c) 2016-2019 Sebastian Pipping <sebastian@pipping.org> + Copyright (c) 2016-2023 Sebastian Pipping <sebastian@pipping.org> Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -42,5 +42,7 @@ # define XML_FMT_INT_MOD "l" #endif +extern int g_read_size_bytes; + extern int XML_ProcessFile(XML_Parser parser, const XML_Char *filename, unsigned flags); diff --git a/xmlwf/xmlwf.c b/xmlwf/xmlwf.c index 471f2a20f57c..7c0a8cd4d6a4 100644 --- a/xmlwf/xmlwf.c +++ b/xmlwf/xmlwf.c @@ -11,13 +11,14 @@ Copyright (c) 2001-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> Copyright (c) 2004-2009 Karl Waclawek <karl@waclawek.net> Copyright (c) 2005-2007 Steven Solie <steven@solie.ca> - Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org> + Copyright (c) 2016-2023 Sebastian Pipping <sebastian@pipping.org> Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk> Copyright (c) 2019 David Loffredo <loffredo@steptools.com> Copyright (c) 2020 Joe Orton <jorton@redhat.com> Copyright (c) 2020 Kleber TarcĂsio <klebertarcisio@yahoo.com.br> Copyright (c) 2021 Tim Bray <tbray@textuality.com> Copyright (c) 2022 Martin Ettl <ettl.martin78@googlemail.com> + Copyright (c) 2022 Sean McBride <sean@rogue-research.com> Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining @@ -40,7 +41,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include <expat_config.h> +#include "expat_config.h" #include <assert.h> #include <stdio.h> @@ -178,7 +179,7 @@ is equivalent to lexicographically comparing based on the character number. */ static int attcmp(const void *att1, const void *att2) { - return tcscmp(*(const XML_Char **)att1, *(const XML_Char **)att2); + return tcscmp(*(const XML_Char *const *)att1, *(const XML_Char *const *)att2); } static void XMLCALL @@ -215,8 +216,8 @@ endElement(void *userData, const XML_Char *name) { static int nsattcmp(const void *p1, const void *p2) { - const XML_Char *att1 = *(const XML_Char **)p1; - const XML_Char *att2 = *(const XML_Char **)p2; + const XML_Char *att1 = *(const XML_Char *const *)p1; + const XML_Char *att2 = *(const XML_Char *const *)p2; int sep1 = (tcsrchr(att1, NSSEP) != 0); int sep2 = (tcsrchr(att2, NSSEP) != 0); if (sep1 != sep2) @@ -370,8 +371,8 @@ xcscmp(const XML_Char *xs, const XML_Char *xt) { static int notationCmp(const void *a, const void *b) { - const NotationList *const n1 = *(NotationList **)a; - const NotationList *const n2 = *(NotationList **)b; + const NotationList *const n1 = *(const NotationList *const *)a; + const NotationList *const n2 = *(const NotationList *const *)b; return xcscmp(n1->notationName, n2->notationName); } @@ -871,6 +872,9 @@ showVersion(XML_Char *prog) { } } +#if defined(__GNUC__) +__attribute__((noreturn)) +#endif static void usage(const XML_Char *prog, int rc) { ftprintf( @@ -883,50 +887,54 @@ usage(const XML_Char *prog, int rc) { /* clang-format off */ T("usage:\n") T(" %s [OPTIONS] [FILE ...]\n") - T(" %s -h\n") - T(" %s -v\n") + T(" %s -h|--help\n") + T(" %s -v|--version\n") T("\n") T("xmlwf - Determines if an XML document is well-formed\n") T("\n") T("positional arguments:\n") - T(" FILE file to process (default: STDIN)\n") + T(" FILE file to process (default: STDIN)\n") T("\n") T("input control arguments:\n") - T(" -s print an error if the document is not [s]tandalone\n") - T(" -n enable [n]amespace processing\n") - T(" -p enable processing external DTDs and [p]arameter entities\n") - T(" -x enable processing of e[x]ternal entities\n") - T(" -e ENCODING override any in-document [e]ncoding declaration\n") - T(" -w enable support for [W]indows code pages\n") - T(" -r disable memory-mapping and use normal file [r]ead IO calls instead\n") - T(" -k when processing multiple files, [k]eep processing after first file with error\n") + T(" -s print an error if the document is not [s]tandalone\n") + T(" -n enable [n]amespace processing\n") + T(" -p enable processing of external DTDs and [p]arameter entities\n") + T(" -x enable processing of e[x]ternal entities\n") + T(" -e ENCODING override any in-document [e]ncoding declaration\n") + T(" -w enable support for [W]indows code pages\n") + T(" -r disable memory-mapping and use [r]ead calls instead\n") + T(" -g BYTES buffer size to request per call pair to XML_[G]etBuffer and read (default: 8 KiB)\n") + T(" -k when processing multiple files, [k]eep processing after first file with error\n") T("\n") T("output control arguments:\n") - T(" -d DIRECTORY output [d]estination directory\n") - T(" -c write a [c]opy of input XML, not canonical XML\n") - T(" -m write [m]eta XML, not canonical XML\n") - T(" -t write no XML output for [t]iming of plain parsing\n") - T(" -N enable adding doctype and [n]otation declarations\n") + T(" -d DIRECTORY output [d]estination directory\n") + T(" -c write a [c]opy of input XML, not canonical XML\n") + T(" -m write [m]eta XML, not canonical XML\n") + T(" -t write no XML output for [t]iming of plain parsing\n") + T(" -N enable adding doctype and [n]otation declarations\n") T("\n") T("billion laughs attack protection:\n") T(" NOTE: If you ever need to increase these values for non-attack payload, please file a bug report.\n") T("\n") - T(" -a FACTOR set maximum tolerated [a]mplification factor (default: 100.0)\n") - T(" -b BYTES set number of output [b]ytes needed to activate (default: 8 MiB)\n") + T(" -a FACTOR set maximum tolerated [a]mplification factor (default: 100.0)\n") + T(" -b BYTES set number of output [b]ytes needed to activate (default: 8 MiB)\n") + T("\n") + T("reparse deferral:\n") + T(" -q disable reparse deferral, and allow [q]uadratic parse runtime with large tokens\n") T("\n") T("info arguments:\n") - T(" -h show this [h]elp message and exit\n") - T(" -v show program's [v]ersion number and exit\n") + T(" -h, --help show this [h]elp message and exit\n") + T(" -v, --version show program's [v]ersion number and exit\n") T("\n") T("exit status:\n") - T(" 0 the input files are well-formed and the output (if requested) was written successfully\n") - T(" 1 could not allocate data structures, signals a serious problem with execution environment\n") - T(" 2 one or more input files were not well-formed\n") - T(" 3 could not create an output file\n") - T(" 4 command-line argument error\n") + T(" 0 the input files are well-formed and the output (if requested) was written successfully\n") + T(" 1 could not allocate data structures, signals a serious problem with execution environment\n") + T(" 2 one or more input files were not well-formed\n") + T(" 3 could not create an output file\n") + T(" 4 command-line argument error\n") T("\n") T("xmlwf of libexpat is software libre, licensed under the MIT license.\n") - T("Please report bugs at https://github.com/libexpat/libexpat/issues. Thank you!\n") + T("Please report bugs at https://github.com/libexpat/libexpat/issues -- thank you!\n") , /* clang-format on */ prog, prog, prog); exit(rc); @@ -940,8 +948,10 @@ int wmain(int argc, XML_Char **argv); #define XMLWF_SHIFT_ARG_INTO(constCharStarTarget, argc, argv, i, j) \ { \ if (argv[i][j + 1] == T('\0')) { \ - if (++i == argc) \ + if (++i == argc) { \ usage(argv[0], XMLWF_EXIT_USAGE_ERROR); \ + /* usage called exit(..), never gets here */ \ + } \ constCharStarTarget = argv[i]; \ } else { \ constCharStarTarget = argv[i] + j + 1; \ @@ -964,9 +974,11 @@ tmain(int argc, XML_Char **argv) { int continueOnError = 0; float attackMaximumAmplification = -1.0f; /* signaling "not set" */ - unsigned long long attackThresholdBytes; + unsigned long long attackThresholdBytes = 0; XML_Bool attackThresholdGiven = XML_FALSE; + XML_Bool disableDeferral = XML_FALSE; + int exitCode = XMLWF_EXIT_SUCCESS; enum XML_ParamEntityParsing paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; @@ -983,9 +995,17 @@ tmain(int argc, XML_Char **argv) { if (j == 0) { if (argv[i][0] != T('-')) break; - if (argv[i][1] == T('-') && argv[i][2] == T('\0')) { - i++; - break; + if (argv[i][1] == T('-')) { + if (argv[i][2] == T('\0')) { + i++; + break; + } else if (tcscmp(argv[i] + 2, T("help")) == 0) { + usage(argv[0], XMLWF_EXIT_SUCCESS); + // usage called exit(..), never gets here + } else if (tcscmp(argv[i] + 2, T("version")) == 0) { + showVersion(argv[0]); + return XMLWF_EXIT_SUCCESS; + } } j++; } @@ -1038,10 +1058,30 @@ tmain(int argc, XML_Char **argv) { break; case T('h'): usage(argv[0], XMLWF_EXIT_SUCCESS); - return 0; + // usage called exit(..), never gets here case T('v'): showVersion(argv[0]); - return 0; + return XMLWF_EXIT_SUCCESS; + case T('g'): { + const XML_Char *valueText = NULL; + XMLWF_SHIFT_ARG_INTO(valueText, argc, argv, i, j); + + errno = 0; + XML_Char *afterValueText = (XML_Char *)valueText; + const long long read_size_bytes_candidate + = tcstoull(valueText, &afterValueText, 10); + if ((errno != 0) || (afterValueText[0] != T('\0')) + || (read_size_bytes_candidate < 1) + || (read_size_bytes_candidate > (INT_MAX / 2 + 1))) { + // This prevents tperror(..) from reporting misleading "[..]: Success" + errno = ERANGE; + tperror(T("invalid buffer size") T( + " (needs an integer from 1 to INT_MAX/2+1 i.e. 1,073,741,824 on most platforms)")); + exit(XMLWF_EXIT_USAGE_ERROR); + } + g_read_size_bytes = (int)read_size_bytes_candidate; + break; + } case T('k'): continueOnError = 1; j++; @@ -1051,7 +1091,7 @@ tmain(int argc, XML_Char **argv) { XMLWF_SHIFT_ARG_INTO(valueText, argc, argv, i, j); errno = 0; - XML_Char *afterValueText = (XML_Char *)valueText; + XML_Char *afterValueText = NULL; attackMaximumAmplification = tcstof(valueText, &afterValueText); if ((errno != 0) || (afterValueText[0] != T('\0')) || isnan(attackMaximumAmplification) @@ -1062,9 +1102,10 @@ tmain(int argc, XML_Char **argv) { " (needs a floating point number greater or equal than 1.0)")); exit(XMLWF_EXIT_USAGE_ERROR); } -#ifndef XML_DTD - ftprintf(stderr, T("Warning: Given amplification limit ignored") T( - ", xmlwf has been compiled without DTD support.\n")); +#if XML_GE == 0 + ftprintf(stderr, + T("Warning: Given amplification limit ignored") + T(", xmlwf has been compiled without DTD/GE support.\n")); #endif break; } @@ -1083,12 +1124,18 @@ tmain(int argc, XML_Char **argv) { exit(XMLWF_EXIT_USAGE_ERROR); } attackThresholdGiven = XML_TRUE; -#ifndef XML_DTD - ftprintf(stderr, T("Warning: Given attack threshold ignored") T( - ", xmlwf has been compiled without DTD support.\n")); +#if XML_GE == 0 + ftprintf(stderr, + T("Warning: Given attack threshold ignored") + T(", xmlwf has been compiled without DTD/GE support.\n")); #endif break; } + case T('q'): { + disableDeferral = XML_TRUE; + j++; + break; + } case T('\0'): if (j > 1) { i++; @@ -1098,6 +1145,7 @@ tmain(int argc, XML_Char **argv) { /* fall through */ default: usage(argv[0], XMLWF_EXIT_USAGE_ERROR); + // usage called exit(..), never gets here } } if (i == argc) { @@ -1120,13 +1168,13 @@ tmain(int argc, XML_Char **argv) { } if (attackMaximumAmplification != -1.0f) { -#ifdef XML_DTD +#if XML_GE == 1 XML_SetBillionLaughsAttackProtectionMaximumAmplification( parser, attackMaximumAmplification); #endif } if (attackThresholdGiven) { -#ifdef XML_DTD +#if XML_GE == 1 XML_SetBillionLaughsAttackProtectionActivationThreshold( parser, attackThresholdBytes); #else @@ -1134,6 +1182,16 @@ tmain(int argc, XML_Char **argv) { #endif } + if (disableDeferral) { + const XML_Bool success = XML_SetReparseDeferralEnabled(parser, XML_FALSE); + if (! success) { + // This prevents tperror(..) from reporting misleading "[..]: Success" + errno = EINVAL; + tperror(T("Failed to disable reparse deferral")); + exit(XMLWF_EXIT_INTERNAL_ERROR); + } + } + if (requireStandalone) XML_SetNotStandaloneHandler(parser, notStandalone); XML_SetParamEntityParsing(parser, paramEntityParsing); diff --git a/xmlwf/xmlwf_helpgen.py b/xmlwf/xmlwf_helpgen.py index c2a527fde27d..3d32f5d148b7 100755 --- a/xmlwf/xmlwf_helpgen.py +++ b/xmlwf/xmlwf_helpgen.py @@ -6,7 +6,7 @@ # \___/_/\_\ .__/ \__,_|\__| # |_| XML parser # -# Copyright (c) 2019-2021 Sebastian Pipping <sebastian@pipping.org> +# Copyright (c) 2019-2023 Sebastian Pipping <sebastian@pipping.org> # Copyright (c) 2021 Tim Bray <tbray@textuality.com> # Licensed under the MIT license: # @@ -33,20 +33,20 @@ import argparse epilog = """ exit status: - 0 the input files are well-formed and the output (if requested) was written successfully - 1 could not allocate data structures, signals a serious problem with execution environment - 2 one or more input files were not well-formed - 3 could not create an output file - 4 command-line argument error + 0 the input files are well-formed and the output (if requested) was written successfully + 1 could not allocate data structures, signals a serious problem with execution environment + 2 one or more input files were not well-formed + 3 could not create an output file + 4 command-line argument error xmlwf of libexpat is software libre, licensed under the MIT license. -Please report bugs at https://github.com/libexpat/libexpat/issues. Thank you! +Please report bugs at https://github.com/libexpat/libexpat/issues -- thank you! """ usage = """ %(prog)s [OPTIONS] [FILE ...] - %(prog)s -h - %(prog)s -v + %(prog)s -h|--help + %(prog)s -v|--version """ parser = argparse.ArgumentParser(prog='xmlwf', add_help=False, @@ -58,11 +58,12 @@ parser = argparse.ArgumentParser(prog='xmlwf', add_help=False, input_related = parser.add_argument_group('input control arguments') input_related.add_argument('-s', action='store_true', help='print an error if the document is not [s]tandalone') input_related.add_argument('-n', action='store_true', help='enable [n]amespace processing') -input_related.add_argument('-p', action='store_true', help='enable processing external DTDs and [p]arameter entities') +input_related.add_argument('-p', action='store_true', help='enable processing of external DTDs and [p]arameter entities') input_related.add_argument('-x', action='store_true', help='enable processing of e[x]ternal entities') input_related.add_argument('-e', action='store', metavar='ENCODING', help='override any in-document [e]ncoding declaration') input_related.add_argument('-w', action='store_true', help='enable support for [W]indows code pages') -input_related.add_argument('-r', action='store_true', help='disable memory-mapping and use normal file [r]ead IO calls instead') +input_related.add_argument('-r', action='store_true', help='disable memory-mapping and use [r]ead calls instead') +input_related.add_argument('-g', metavar='BYTES', help='buffer size to request per call pair to XML_[G]etBuffer and read (default: 8 KiB)') input_related.add_argument('-k', action='store_true', help='when processing multiple files, [k]eep processing after first file with error') output_related = parser.add_argument_group('output control arguments') @@ -81,12 +82,16 @@ billion_laughs.add_argument('-a', metavar='FACTOR', help='set maximum tolerated [a]mplification factor (default: 100.0)') billion_laughs.add_argument('-b', metavar='BYTES', help='set number of output [b]ytes needed to activate (default: 8 MiB)') +reparse_deferral = parser.add_argument_group('reparse deferral') +reparse_deferral.add_argument('-q', metavar='FACTOR', + help='disable reparse deferral, and allow [q]uadratic parse runtime with large tokens') + parser.add_argument('files', metavar='FILE', nargs='*', help='file to process (default: STDIN)') info = parser.add_argument_group('info arguments') info = info.add_mutually_exclusive_group() -info.add_argument('-h', action='store_true', help='show this [h]elp message and exit') -info.add_argument('-v', action='store_true', help='show program\'s [v]ersion number and exit') +info.add_argument('-h', '--help', action='store_true', help='show this [h]elp message and exit') +info.add_argument('-v', '--version', action='store_true', help='show program\'s [v]ersion number and exit') if __name__ == '__main__': |
