Commit graph

3983 commits

Author SHA1 Message Date
clang-format
a392427d3a Mass-apply clang-format 17.0.3 using ./apply-clang-format.sh 2023-10-20 23:49:51 +02:00
Sebastian Pipping
0cfeab4f1c
Merge pull request #772 from libexpat/tests-warnings-mingw
tests/memcheck.c: Avoid false positive -Wuse-after-free
2023-10-20 23:49:06 +02:00
Sebastian Pipping
eeab6366b0 tests/memcheck.c: Avoid false positive -Wuse-after-free
Symptom was this compile warning from MinGW GCC 12:
> [..]/expat/tests/memcheck.c: In function ‘tracking_realloc’:
> [..]/expat/tests/memcheck.c:169:25: error: pointer ‘ptr’ may be used after ‘realloc’ [-Werror=use-after-free]
>   169 |       entry->allocation = ptr;
>       |       ~~~~~~~~~~~~~~~~~~^~~~~
> [..]/expat/tests/memcheck.c:166:25: note: call to ‘realloc’ here
>   166 |     entry->allocation = realloc(ptr, size);
>       |                         ^~~~~~~~~~~~~~~~~~

The warning is a false positive since the code was only using ptr
when realloc failed where it is documented that the original pointer is
not freed.

The workaround is to no longer override-and-restore entry->allocation
but to only write to it when realloc was successful.  The original
value was equal to ptr so the result is the same.
2023-10-20 20:19:37 +02:00
Sebastian Pipping
a68399a05b
Merge pull request #770 from libexpat/xmlwf-sync-man-page
xmlwf: Get man page back in sync (i.e. add `--help`, `--version` and `-g <bytes>`)
2023-10-18 21:46:41 +02:00
Sebastian Pipping
4d475d97d6 doc/xmlwf.xml: Add missing entry on "-g <bytes>" 2023-10-18 16:48:03 +02:00
Sebastian Pipping
1746075001 doc/xmlwf.xml: Add missing entry on -h|--help 2023-10-18 16:48:03 +02:00
Sebastian Pipping
114cb042ae doc/xmlwf.xml: Add --help and --version where missing 2023-10-18 16:48:03 +02:00
Sebastian Pipping
28347d9586
Merge pull request #764 from libexpat/xml-context-bytes-zero
Be stricter about macro XML_CONTEXT_BYTES at build time
2023-10-06 14:21:36 +02:00
Sebastian Pipping
96985a1a07 lib/xmlparse.c: Make clang-format 16.0.6 happy again 2023-10-05 15:44:10 +02:00
Sebastian Pipping
23110a864d Be stricter about macro XML_CONTEXT_BYTES
- Start treating -DXML_CONTEXT_BYTES=0 as "no context"
  rather than "context of size 0".  Was documented as
  "must be set to a positive integer", previously.

- Enforce that macro XML_CONTEXT_BYTES is defined at build time to
  avoid accidental misbuilds lacking context in environments that
  bypass both of Expats official build systems.

- Detect and reject use of negative context size at compile time.
2023-10-05 15:44:10 +02:00
Sebastian Pipping
acbcd0915d
Merge pull request #766 from libexpat/doc-parse-buffer-variables
lib/xmlparse.c: Improve parse buffer variables documentation
2023-10-05 14:50:10 +02:00
Sebastian Pipping
32f64cf174
Merge pull request #762 from libexpat/doc-reference-html-promote-xml-parsebuffer-more
doc/reference.html: Promote function XML_ParseBuffer more
2023-10-05 14:49:29 +02:00
Sebastian Pipping
3ae5431d22
Merge pull request #765 from libexpat/consistent-expat-config-h-includes
Make inclusion to expat_config.h consistent
2023-10-05 01:35:26 +02:00
Sebastian Pipping
dd34d0e65c lib/xmlparse.c: Improve parse buffer variables documentation 2023-10-04 22:40:31 +02:00
Sebastian Pipping
ab43d8d116 Make inclusion to expat_config.h consistent
.. and priorize the local build over the system header.
2023-10-04 19:58:28 +02:00
Sebastian Pipping
1d3ee5133e doc/reference.html: Make XML_Parse promote XML_ParseBuffer 2023-10-04 18:01:31 +02:00
Sebastian Pipping
81a705b6ae doc/reference.html: Wrap paragraphs by <p> for function XML_Parse 2023-10-03 23:25:09 +02:00
Sebastian Pipping
60654a3255
Merge pull request #763 from libexpat/fix-codespell-ci
Fix codespell CI + mass-replace "re-use[d]" by "reuse[d]"
2023-10-03 23:23:29 +02:00
Sebastian Pipping
c135d7a118 codespell.yml: Ignore "[p]arameter" in xmlwf help output 2023-10-03 21:33:55 +02:00
Sebastian Pipping
c1d4c439a1 docs: Mass-replace "re-use[d]" by "reuse[d]"
Pointed out by codespell.
2023-10-03 21:33:55 +02:00
Sebastian Pipping
1763071577
Merge pull request #761 from libexpat/xmlwf-help-version
xmlwf: Support --help and --version
2023-09-29 17:48:21 +02:00
Sebastian Pipping
92cdc783f1 xmlwf: Get help output alignment back in order 2023-09-29 12:55:17 +02:00
Sebastian Pipping
4c6731ad11 xmlwf: Use XMLWF_EXIT_SUCCESS where missing 2023-09-29 12:55:17 +02:00
Sebastian Pipping
0b3ef852bc xmlwf: Support --help and --version 2023-09-29 12:55:17 +02:00
Sebastian Pipping
900d2a7cd2 xmlwf: Better document that usage(..) calls exit(..) 2023-09-29 12:55:17 +02:00
Sebastian Pipping
bc26bc5896 xmlwf: Break up conditional before upcoming extension 2023-09-29 12:06:05 +02:00
Sebastian Pipping
8741d2a1db
Merge pull request #760 from libexpat/doc-reference-html-okcss-1-2-0
doc/reference.html: Upgrade to OK.css 1.2.0
2023-09-29 11:42:12 +02:00
Sebastian Pipping
0cf825c342 doc/reference.html: Add paragraph wrap for XML_ParserCreate
.. in order to fix styling.
2023-09-28 21:00:00 +02:00
Sebastian Pipping
08efcde3be
Merge pull request #759 from libexpat/xmlwf-custom-buffer-size
xmlwf: Support custom buffer size for XML_GetBuffer and read
2023-09-28 20:54:24 +02:00
Sebastian Pipping
cc3079f149 doc/reference.html: Upgrade to OK.css 1.2.0 2023-09-28 20:13:12 +02:00
Sebastian Pipping
d248e7e923 xmlwf: Support custom buffer size for XML_GetBuffer and read 2023-09-28 17:06:39 +02:00
Sebastian Pipping
f2a9d1155b
Merge pull request #758 from SonyMobile/chunk-tests-with-0
Run SINGLE_BYTES with no chunking, too
2023-09-28 15:47:44 +02:00
Snild Dolkow
091ba48d7a tests: Run SINGLE_BYTES with no chunking
...in addition to 1-to-5-byte chunks as we've done so far.

By starting g_chunkSize at 0, we get to run all the tests that call
_XML_Parse_SINGLE_BYTES() as if they just called XML_Parse(). This
gives us extra test coverage.
2023-09-28 13:49:41 +02:00
Snild Dolkow
7b0e27a698 tests: Replace invalid entity expansion in test_alloc_nested_entities
%pe2; would ultimately expand to a plain "ABCDEF...", which is not
valid in this context. This was not normally hit, since the test would
get its expected XML_ERROR_NO_MEMORY before expanding this far.

With g_chunkSize=0 and EXPAT_CONTEXT_BYTES=OFF, the number of allocs
required to reach that point becomes *just* low enough to reach the
final expansion, making the test fail with a very unexpected syntax
error.

Nesting %pe2; in another entity declaration avoids the problem.
2023-09-28 13:49:41 +02:00
Snild Dolkow
b4d2b76a97 tests: Exit parser_stop_character_handler if parser is finished
When test_repeated_stop_parser_between_char_data_calls runs without
chunking the input -- which I am about to do in my next commit -- the
parser_stop_character_handler callback happens multiple times. This is
because stopping the parser doesn't stop all callbacks immediately,
which is valid (documented) behavior.

The second callback tried to stop the parser again, getting unexpected
errors. Let's check the parser status on entry and return early if it's
already finished.
2023-09-28 13:49:41 +02:00
Sebastian Pipping
e1dc3383e3
Merge pull request #757 from SonyMobile/more-is-final
Add isFinal=XML_TRUE to more tests
2023-09-27 17:37:56 +02:00
Snild Dolkow
a5993b2d42 tests: Remove early comment count check in test_user_parameters
Before a parse call with isFinal=XML_TRUE, there is no guarantee that
all supplied data has been parsed. Removing the first comment count
check removes the test's assumption of such a guarantee.
2023-09-26 10:33:43 +02:00
Snild Dolkow
bb3c171980 tests: set isFinal in test_reset_in_entity
Without this, parsing may be deferred so that the suspending callback
hasn't been called when the test checks for it.
2023-09-26 10:33:43 +02:00
Snild Dolkow
2e12534145 tests: set isFinal in test_line_number_after_parse
Without this, parsing of the start or end tag may be deferred, yielding
an unexpected line number.
2023-09-26 10:33:43 +02:00
Sebastian Pipping
2ed4410e07
Merge pull request #756 from libexpat/dependabot/github_actions/actions/checkout-4.1.0
Actions(deps): Bump actions/checkout from 4.0.0 to 4.1.0
2023-09-25 16:06:29 +02:00
Sebastian Pipping
365b156d9d
Merge pull request #755 from SonyMobile/chunk-tests
Repeat tests with different SINGLE_BYTES chunk sizes
2023-09-25 15:27:42 +02:00
dependabot[bot]
b63e902b8f
Actions(deps): Bump actions/checkout from 4.0.0 to 4.1.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 4.0.0 to 4.1.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](3df4ab11eb...8ade135a41)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-25 12:48:26 +00:00
Snild Dolkow
1d8ceb26aa tests: Run SINGLE_BYTES with variously-sized chunks
The _XML_Parse_SINGLE_BYTES function currently calls XML_Parse() one
byte at a time. This is useful to detect possible parsing bugs related
to having to exit parsing, wait for more data, and resume.

This commit makes SINGLE_BYTES even more useful by repeating all tests,
changing the chunk size every time. So instead of just one byte at a
time, we now also test two bytes at a time, and so on. Tests that don't
use the SINGLE_BYTES also run multiple times, but are otherwise not
affected.

This uncovered some issues, which have been fixed in preceding commits.

On failure, the chunk size is included in the "FAIL" log prints.
2023-09-25 14:01:53 +02:00
Snild Dolkow
4978d285d2 tests: Look for single-char match in test_abort_epilog
...instead of a full-string match.

These tests were depending on getting handler callbacks with exactly
one character of data at a time. For example, if test_abort_epilog got
"\n\r\n" in one callback, it would fail to match on the '\r', and would
not abort parsing as expected.

By searching the callback arg for the magic character rather than
expecting a full match, the test no longer depends on exact callback
timing.

`userData` is never NULL in these tests, so that check was left out of
the new version.
2023-09-25 14:01:53 +02:00
Snild Dolkow
7474fe3d3f tests: Make test_default_current insensitive to callback chunking
Instead of testing the exact number and sequence of callbacks, we now
test that we get the exact data lengths and sequence of callbacks. The
checks become much more verbose, but will now accept any buffer fill
strategy -- single bytes, multiple bytes, or any combination thereof.
2023-09-25 14:01:46 +02:00
Snild Dolkow
a4a4552313 tests: Add subtest names to test_default_current 2023-09-25 08:45:37 +02:00
Snild Dolkow
d825624d92 minicheck: Add fail_unless() macro
...and fix _fail_unless() so that it doesn't always fail. All existing
calls to it pass 0, so there's no immediate change in behavior in this
commit.
2023-09-25 08:45:37 +02:00
Donghee Na
e52b6b8b8c Update legal name of Donghee Na (#754) 2023-09-24 18:13:03 +02:00
Sebastian Pipping
bcdc25b04d
Merge pull request #753 from SonyMobile/consume-bom
Fix parse-size-dependent "invalid token" error for external entities that start with a byte order mark
2023-09-22 18:06:57 +02:00
Snild Dolkow
b1e955449c Always consume BOM bytes when found in prolog
The byte order mark is not correctly consumed when followed by an
incomplete token in a non-final parse. This results in the BOM staying
in the buffer, causing an invalid token error later.

This was not detected by existing tests because they either parse
everything in one call, or add a single byte at a time.

By moving `s` forward when we find a BOM, we make sure that the BOM
bytes are properly consumed in all cases.
2023-09-22 17:14:22 +02:00