0
0
mirror of https://github.com/zeux/pugixml.git synced 2025-01-13 17:37:58 +08:00

1777 Commits

Author SHA1 Message Date
David Seifert
44236fef2c
Fix -Wuseless-cast 2023-11-13 20:53:44 -08:00
Arseny Kapoulkine
6909df2478
Merge pull request #590 from zeux/sanfuzz
Update config=sanitize and fuzz targets
2023-10-22 11:18:08 -07:00
Arseny Kapoulkine
b15bc6bf1f Update config=sanitize and fuzz targets
We used to need to silence float-divide-by-zero and float-cast-overflow
sanitizers since clang used a finite valid floating point value range.
Fortunately, since clang-9 UBSAN properly handles various primitive
operations per IEEE-754 so we no longer need this workaround.

Also use fork=16 mode for fuzz targets to make it easier to run fuzzing
locally.
2023-10-22 10:07:52 -07:00
Arseny Kapoulkine
33f709379a
Merge pull request #551 from silvergasp/master
fuzzer: excersizes query code on xml doc
2023-10-21 12:29:22 -07:00
Arseny Kapoulkine
4d42ba7a60
Update fuzz_xpath.cpp
Remove unused variables
2023-10-21 11:20:03 -07:00
Arseny Kapoulkine
d75a081aa3
Update fuzz_xpath.cpp
Fix code style, no exceptions, other tweaks.
2023-10-21 11:11:11 -07:00
Arseny Kapoulkine
1ade1d4bea
Merge pull request #586 from PhilipBotha/fix/nullptr_const_zero
Replaced 0 with PUGIXML_NULL when a nullptr would have been needed.
2023-10-19 19:21:08 -07:00
Arseny Kapoulkine
94b19a3c45 Fix indentation changes 2023-10-15 19:25:56 -07:00
Arseny Kapoulkine
76dec417a6 Silence -Wzero-as-null-pointer-constant for clang
clang does not handle NULL the same way as gcc, so for now we silence
the warning.
2023-10-15 19:19:36 -07:00
Arseny Kapoulkine
6699559320 Replace 0 with NULL for some MSVC-specific code 2023-10-15 19:17:37 -07:00
Arseny Kapoulkine
dab3a2f858 Replace 0 with NULL for compact and wchar mode specific code 2023-10-15 19:13:34 -07:00
Arseny Kapoulkine
60d9656cb7 Replace PUGIXML_NULL with NULL and fix a couple extra stragglers 2023-10-15 19:10:34 -07:00
Philip
08b966e24f Fixed zero as nullptr constant in macro.
Removed white space that was changed.
2023-10-14 09:06:20 +02:00
Arseny Kapoulkine
2e357d19a3
Merge pull request #585 from ilya-lavrenov/install-rules
Added cmake option to disable install rules
2023-10-13 20:14:59 -07:00
Philip Botha
b138778fd9 Replaced 0 with PUGIXML_NULL when appropriate.
Added the suffix UZ to size_t.

Added fixed GCC warning about using const literal zero in place of nullptr (-Wzero-as-null-pointer-constant).
2023-10-12 15:49:18 +02:00
Ilya Lavrenov
3cfe51b72d Added cmake option to disable install rules 2023-10-12 02:15:05 +04:00
Arseny Kapoulkine
ef856bf975
Merge pull request #584 from richardapeters/master
build: only include CTest when building the pugixml tests
2023-10-06 06:14:27 -07:00
Richard Peters
efce4a8d7a Remove BUILD_TESTING as prerequisite for the PUGIXML_BUILD_TESTS; it was always set by including CTest, now CTest is conditionally included later on 2023-10-06 10:02:15 +02:00
Richard Peters
a468d5c438 Only include CTest when building the pugixml tests 2023-10-06 09:51:29 +02:00
Arseny Kapoulkine
db78afc2b7 Update version to 1.14 everywhere v1.14 2023-09-07 11:55:13 -07:00
Arseny Kapoulkine
bd70bd7662 docs: Update release notes and regenerate HTML documentation
The large amount of changes seems to be due to asciidoctor now omitting
empty spans in formatted code.
2023-09-07 11:52:15 -07:00
Arseny Kapoulkine
1a9a41b0f4 Update copyright year (2022 => 2023) 2023-09-06 20:39:25 -07:00
Arseny Kapoulkine
1118066f0b
Merge pull request #576 from vineethkuttan/Merge-pcdata-#546
Implement parse_merge_pcdata
2023-09-06 08:01:56 -07:00
Arseny Kapoulkine
ff56985924 Rename merged to merged_pcdata for clarity. 2023-09-06 07:54:14 -07:00
Arseny Kapoulkine
30adb1713b Use memmove instead of strcat
strcat does not allow overlapping ranges; we didn't have a test for this
but now we do.

As an added bonus, this also means we only compute the length of each
fragment once now.
2023-09-05 22:43:55 -07:00
Arseny Kapoulkine
58616a29aa Avoid store-load penalty on cursor->parent
This reclaims the performance lost in PCDATA reorganization and gains a
little more on top of that.
2023-09-05 22:23:31 -07:00
Arseny Kapoulkine
dfb2b7f7b4 Cache ~last position of merged PCDATA
This allows us to fix the quadratic complexity of parse_merge_pcdata.
After parsing the first PCDATA we need to advance by its length; we
still compute the length of each fragment twice with this approach, but
it's constant time.
2023-09-05 21:34:02 -07:00
Arseny Kapoulkine
efb76c1128 docs: Update external XPath links
Both w3schools tutorial and the W3C spec have changed their URLs; I
don't think we actually need the second tutorial so we can simply drop
that one.
2023-08-28 21:26:09 -07:00
Arseny Kapoulkine
bf42c4c568 Reorder set_value/set size_t overloads and change sz to size
This makes the source order and naming match documentation.
2023-08-26 08:41:37 -07:00
Arseny Kapoulkine
5a33d2b1d7 docs: Add forgotten set_name overloads to API reference 2023-08-26 08:38:42 -07:00
Arseny Kapoulkine
e9d17a045e Streamline conditions with else if 2023-08-26 08:35:40 -07:00
Arseny Kapoulkine
08a5048f15
Merge pull request #537 from stefanroellin/size-t-overloads
Add overloads with size_t type argument
2023-08-26 08:27:34 -07:00
Stefan Roellin
f4d4316eba Add overloads with size_t type argument
* bool xml_attribute::set_name(const char_t* rhs, size_t sz)
* bool xml_node::set_name(const char_t* rhs, size_t sz)
2023-08-26 11:30:49 +02:00
Arseny Kapoulkine
6749789ec4 Fix interaction between parse_merge_pcdata and append_buffer
strconcat in the parsing loop only works if we know the source string
comes from the same buffer that we're parsing. This is somewhat
cumbersome to establish during parsing and it requires extra tracking
data, so we just disable this combination as it's unlikely to be
actually useful - usually append_buffer would be called on a possibly
empty collection of elements, not on something with PCDATA.
2023-08-25 19:32:42 -07:00
Arseny Kapoulkine
f31ad2c1ab tests: Add more tests for parse_merge_pcdata
Add tests for double escape and a test for interaction with
parse_ws_pcdata flags; this behavior might change but we should pin the
current result.

Also slightly clean up the previously added test.
2023-08-25 19:20:23 -07:00
Arseny Kapoulkine
37ba937e05 Fix code style and simplify conditions
prev_sibling_c is never NULL so it should be safe to check first_child
instead, which ensures we may the minumum cost when the feature isn't
enabled.
2023-08-25 18:57:06 -07:00
Arseny Kapoulkine
0189471a3a docs: Fix up grammar 2023-08-25 18:48:32 -07:00
Arseny Kapoulkine
c72a210ff7 tests: Add more tests for empty text setup
Here we also test what happens when text gets assigned to an empty
string after initially being non-empty, to make sure this is not
different from the initial state.
2023-08-25 18:15:36 -07:00
Vineeth
3ad133a2ad Review Changes
i)Indentation added
ii)Optimal parsing ensured
2023-08-23 08:12:57 +05:30
vineeth-11316
a28252205a Final Commit 2023-08-20 10:21:26 +05:30
vineeth-11316
068aa22b1a documentation Change 2023-08-19 09:54:01 +05:30
vineeth-11316
e15adbe704 Intial Commit for merge_pcdata 2023-08-19 09:17:54 +05:30
Arseny Kapoulkine
980cf57ff4 XPath: Account for non-English locales during number->string conversion
We use a special number formatting routine to generate the XPath
REC-compliant number representation; it relies on being able to get a
decimal representation of the source number, which we use sprintf for as
a fallback.

This is fairly insensitive to current locale, except for an assertion
that validates the decimal point as a precaution, and this check
triggers when the locale decimal point is not a dot.

Ideally we'd use a locale-insensitive routine here. On some systems we
have ecvt_r (similarly to MSVC's ecvt_s), but it's deprecated so
adopting it might be fraught with peril.

For now let's simply adjust the assertion to account for locales with
comma as a separator. This is probably not fully comprehensive but
probably gets us from a 90% solution to a 99% solution...

Fixes #574.
2023-07-27 09:24:10 -07:00
Arseny Kapoulkine
187cf6b5a5
Merge pull request #573 from asmaloney/min-cmake-version
{cmake} Fix deprecation warning by updating min version to 3.5
2023-07-19 21:30:01 -07:00
Andy Maloney
b047f46e2c {cmake} Fix deprecation warning by updating min version to 3.5
With CMake 3.27, we get a deprecation warning:

"Compatibility with CMake < 3.5 will be removed from a future version of CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions."

Bump min version to 3.5 to remove warning.
2023-07-19 09:20:14 -04:00
Arseny Kapoulkine
f75dc6dd10
Merge pull request #566 from ArchXUser/master
Fix compilation errors on old GCC (2.95.3, 3.3.5)
2023-05-10 19:55:43 -07:00
Sergey Abramov
1e9636303e Fix compilation errors on old GCC (2.95.3, 3.3.5) 2023-05-11 09:04:22 +07:00
Arseny Kapoulkine
80a531ee1d
Merge pull request #563 from zeux/cmake-oof
build: Fix CMake PUGIXML_STATIC_CRT behavior
2023-04-22 08:01:01 -07:00
Arseny Kapoulkine
8d18de8f46
Merge pull request #550 from asmaloney/fix-weak-vtable-warning
Fix weak vtable warning regarding xml_writer
2023-04-21 15:59:19 -07:00
Andy Maloney
058fc601a1 Fix weak vtable warning regarding xml_writer
Using Apple clang (clang-1400.0.29.202) with `-Wweak-vtables` would produce the following warning:

'xml_writer' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit [-Wweak-vtables]
2023-04-21 17:23:38 -04:00
Arseny Kapoulkine
750e20323b build: Fix CMake PUGIXML_STATIC_CRT behavior
Implementation of PUGIXML_STATIC_CRT for newer CMake versions (3.15+)
depend on MSVC_RUNTIME_LIBRARY, but this only works if the policy
is defined *before* the project.
2023-04-21 13:24:59 -07:00
Arseny Kapoulkine
f4b89469b3
Merge pull request #561 from zeux/file-size
Fix get_file_size behavior inconsistency for folders
2023-04-21 12:52:17 -07:00
Arseny Kapoulkine
a13b5cc08d Use stricter subset for now to avoid compat issues with Unix-like platforms 2023-04-15 13:41:15 -07:00
Arseny Kapoulkine
d3199a0c39 Fix get_file_size behavior inconsistency for folders
Different OSes have different behavior when trying to fopen/fseek/ftell
a folder. On Linux, some systems return 0 size, some systems return an
error, and some systems return LONG_MAX. LONG_MAX is particularly
problematic because that causes spurious OOMs under address sanitizer.

Using fstat manually cleans this up, however it introduces a new
dependency on platform specific headers that we didn't have before, and
also has unclear behavior on 64-bit systems wrt 32-bit sizes which will
need to be tested further as I'm not certain if the behavior needs to be
special-cased only for MSVC/MinGW, which are currently not handled by
this path (unless MinGW defines __unix__...)
2023-04-15 12:48:59 -07:00
Arseny Kapoulkine
e383ce5d82 docs: Update HTML documentation 2023-03-19 15:41:31 -07:00
Arseny Kapoulkine
02930331f8 docs: Add a note to parse_fragment documentation
Fixes #554
2023-03-19 15:41:12 -07:00
Arseny Kapoulkine
a469fa2cfc Add assertion about header-dest relation to strcpy_insitu
May improve static analysis behavior for #555.
2023-03-19 14:57:10 -07:00
Arseny Kapoulkine
544b0a49eb
Merge pull request #559 from SoapGentoo/fix-Wreserved-macro-identifier
Fix `-Wreserved-macro-identifier`
2023-03-19 10:37:20 -07:00
David Seifert
36aa487e9c
Fix -Wreserved-macro-identifier
* https://eel.is/c++draft/lex.name#3.1
  "Each identifier that contains a double underscore __ [...] is reserved to the implementation for any use."
2023-03-19 17:10:53 +01:00
Arseny Kapoulkine
8a679cfe78
Merge pull request #557 from jiangqucheng/master
#556 fix makefile err in some env
2023-03-16 19:03:14 -07:00
jiangqucheng
ddd3cfa4bf #556 fix makefile err in some env 2023-03-16 05:05:16 +00:00
Nathaniel Brough
9d8d193288 tests: excersizes query code on xml doc 2023-03-09 17:46:23 -08:00
Arseny Kapoulkine
c2c61a5905 Add a cautionary comment to xml_node::children(name)
Fixes #538
2023-01-23 09:37:11 -08:00
Arseny Kapoulkine
95683943bb
Merge pull request #533 from DavidKorczynski/cifuzz-int
Add Github CIFuzz action
2022-11-21 11:15:36 +01:00
David Korczynski
7e8a42ee31 CI: decrease fuzzing time from 300s to 30s
Signed-off-by: David Korczynski <david@adalogics.com>
2022-11-20 14:42:49 -08:00
David Korczynski
5cfa7f90f1 Add Github CIFuzz action
Signed-off-by: David Korczynski <david@adalogics.com>
2022-11-18 15:40:54 -08:00
Arseny Kapoulkine
1dc3266fff docs: Add missing documentation for xml_node::attribute with hint
The feature was added in 2015 but somehow was never documented.
2022-11-08 16:49:34 -08:00
Arseny Kapoulkine
cb217f5a85
Merge pull request #530 from zeux/snprintf
Fix Xcode 14 sprintf deprecation warning
2022-11-06 15:09:53 -08:00
Arseny Kapoulkine
e11e0c965f Fix comment typo. 2022-11-06 13:47:53 -08:00
Arseny Kapoulkine
b6b747244e Adjust the workaround for -pedantic mode and fix tests 2022-11-06 10:21:35 -08:00
Arseny Kapoulkine
8be081fbbe Fix Xcode 14 sprintf deprecation warning
We use snprintf when stdc is set to C++11, however in C++98 mode we can't use variadic macros,
and Xcode 14 complains about the use of sprintf.

It should be safe however to use variadic macros on any remotely recent version of clang on Apple,
unless -pedantic is defined which warns against the use of variadic macros in C++98 mode...

This change fixes the problem for the builds that don't specify -pedantic, which is a problem for
another day.
2022-11-06 10:16:21 -08:00
Arseny Kapoulkine
a0e0643363
Merge pull request #526 from zeux/newver
Prepare for 1.13 release
v1.13
2022-10-28 16:53:25 -07:00
Arseny Kapoulkine
3bd1f452b5 Fix version check in test 2022-10-20 20:23:26 -07:00
Arseny Kapoulkine
c5b288d91a Update HTML documentation 2022-10-20 20:20:45 -07:00
Arseny Kapoulkine
0ef3da1e6e Update release notes and manual for 1.13
This includes a previously unnoticed link fix for xml_text::set
2022-10-20 20:18:08 -07:00
Arseny Kapoulkine
76dcd89427 Update version number in preparation for 1.13 2022-10-20 20:08:52 -07:00
Arseny Kapoulkine
43ef7e25d9
Merge pull request #525 from bruxisma/master
Fix exported symbols under clang-cl (Closes #503)
2022-10-20 19:49:48 -07:00
Izzy Muerte
ab8af53059 Fix exported symbols under clang-cl (Closes #503)
This also turns the define for PUGIXML_API into an `$<IF:>`, instead of an
`$<IF:>` with an empty true condition. If this is inadequate, I will
undo it, and place them on separate lines as they were before, but will
most likely use an inverse `$<NOT:>` instead of an `$<IF:>`.
2022-10-20 13:35:49 -07:00
Arseny Kapoulkine
86c9105154
Merge pull request #523 from zeux/ferrh
Fix error handling in xml_document::save_file
2022-10-09 09:08:50 -07:00
Arseny Kapoulkine
444963e269 Fix error handling in xml_document::save_file
There were two conditions under which xml_document::save_file could
previously return true even though the saving failed:

- The last write to the file was buffered in stdio buffer, and it's that
  last write that would fail due to lack of disk space
- The data has been written correctly but fclose failed to update file
  metadata, which can result in truncated size / missing inode updates.

This change fixes both by adjusting save_file to fflush before the check,
and also checking fclose results. Note that while fflush here is
technically redundant, because it's implied by fclose, we must check
ferror explicitly anyway, and so it feels a little cleaner to do most of
the error handling in save_file_impl, so that the changes of fclose()
failing are very slim.

Of course, neither change guarantees that the contents of the file are
going to be safe on disk following a power failure.
2022-10-07 22:13:04 -07:00
Arseny Kapoulkine
0cb4f02579 Final tweaks after #522
This cleans up xml_attribute::set_value to be uniform wrt
xml_node::set_value and xml_text::set_value - for now we duplicate the
body since the logic is trivial and this keeps debug performance
excellent.
2022-10-07 21:46:27 -07:00
Arseny Kapoulkine
c342266fae
Merge pull request #522 from Ferenc-/followup-on-pr-490
Followup on pr 490
2022-10-07 21:42:41 -07:00
Ferenc Géczi
39e169285c Add test for xml_attribute::set_value with size argument 2022-09-29 00:00:00 +00:00
Ferenc Géczi
1905284494 Add test for xml_node::set_value with size argument 2022-09-29 00:00:00 +00:00
Ferenc Géczi
d359402311 Add xml_text::set test with size set to substring 2022-09-29 00:00:00 +00:00
Ferenc Géczi
09e7cc9b1c Add test for xml_text::set with size argument 2022-09-29 00:00:00 +00:00
Ferenc Géczi
f327371219 Add overloads with size_t type argument
* xml_node::set_value(const char_t* rhs, size_t sz)
* xml_text::set(const char_t* rhs, size_t sz)

Signed-off-by: Ferenc Géczi <ferenc.gm@gmail.com>
2022-09-29 18:26:05 +00:00
Arseny Kapoulkine
bcf483c3b7
Merge pull request #492 from KDAB/fix-default-visibility
Correctly set default visibility on non-windows compilers
2022-09-27 12:53:06 -07:00
Milian Wolff
173a263490 Correctly set default visibility on non-windows compilers
This fixes compilation of pugixml with -fvisibility=hidden. Without
this patch, one would get lots of unresolved symbols when consuming
pugixml as a shared library.
2022-09-25 11:37:48 +02:00
Arseny Kapoulkine
521b2cd854 Add issue templates to try to route questions to Discussions 2022-09-02 21:42:25 -07:00
Arseny Kapoulkine
27bc68ab45
Merge pull request #506 from brandl-muc/nullptr_for_msvc
Enable usage of nullptr for MSVC 16 and newer (MSVS 2010)
2022-08-04 08:46:13 -07:00
Matthäus Brandl
f7de324855 Enable usage of nullptr for MSVC 16 and newer (MSVS 2010) 2022-08-04 16:59:37 +02:00
Arseny Kapoulkine
3b5c1fb022 tests: Fix MSVC 2005 build
... I forgot we still support platforms without C99, 23 years later.
2022-07-21 21:17:17 -07:00
Arseny Kapoulkine
ab8453c572 tests: Use snprintf instead of sprintf
sprintf now results in a deprecation warning in Xcode 14 beta.
2022-07-21 20:51:26 -07:00
Arseny Kapoulkine
2639dfd053
Merge pull request #477 from zeux/compactopt
Optimize compact mode
2022-05-31 20:00:01 -05:00
Arseny Kapoulkine
0401559dde
Merge pull request #498 from zeux/fix-oom-safer
Fix memory leak during OOM in convert_buffer
2022-05-16 20:50:07 -07:00
Arseny Kapoulkine
832a4f4914 Use more idiomatic code in this codebase 2022-05-16 19:14:29 -07:00
Arseny Kapoulkine
33a75c734b Fix memory leak during OOM in convert_buffer
This is the same fix as #497, but we're using auto_deleter instead
because if allocation function throws, we can't rely on an explicit call
to deallocate.

Comes along with two tests that validate the behavior.
2022-05-16 19:12:52 -07:00
Arseny Kapoulkine
ec851bb18d
Merge pull request #497 from TodorHryn/master
Fix memory leak
2022-05-16 19:05:29 -07:00
TodorHryn
6fbf32140b Fix memory leak 2022-05-16 13:21:20 +03:00