Commit Graph

774 Commits

Author SHA1 Message Date
deal
ce19f19632
Merge branch 'zeux:master' into dev 2022-02-16 17:32:19 +08:00
Arseny Kapoulkine
dd50fa5b45 Fix PUGIXML_VERSION macro
Also make sure the line shows up in grep when using the current version
number.

Fixes #478.
2022-02-10 08:36:19 -08:00
Arseny Kapoulkine
25c4fb74a8 Update copyright year to 2022 2022-02-08 19:58:58 -08:00
Arseny Kapoulkine
c9e219c17b Update version to 1.12 2022-02-08 19:56:41 -08:00
Arseny Kapoulkine
9ba92a7fa7 Restore compatibility with WinCE
WinCE lacks most recent CRT additions to MSVC; we used to explicitly disable specific sections
of code, but it's more comprehensive to just specify that the CRT is from MSVC7 instead of MSVC8.

Fixes #401
2022-02-08 19:19:34 -08:00
halx99
6c2bb13a44 Fix ci 2022-02-08 21:52:04 +08:00
halx99
d6fac0ac39 More string_view 2022-02-08 21:41:28 +08:00
halx99
c95044df05 Fix for compact mode 2021-12-24 14:01:46 +08:00
deal
3ceb703935
Update pugixml.cpp 2021-12-24 01:54:39 +08:00
halx99
d3a8b86f17 Add missing commit from shallow_copy branch 2021-12-23 21:14:51 +08:00
halx99
f0259eb00a Fix ci 2021-12-23 19:14:53 +08:00
halx99
32cccfe377 Use string_view for all dom APIs 2021-12-23 18:44:32 +08:00
halx99
b634ea55df Node copy avoid stringlen operation 2021-12-23 17:17:33 +08:00
halx99
7791e7dfbb Store length for setters 2021-12-23 16:55:08 +08:00
halx99
9129d7900c Fix ci 2021-12-23 16:15:30 +08:00
halx99
b025069fbe Fix for old compilers 2021-12-23 16:11:40 +08:00
deal
4e4af11838
Fix warnings on PUGIXML_WCHAR_MODE 2021-12-23 16:05:36 +08:00
halx99
69e24c7fdd Add string_view name & value getter with suffix for compatible 2021-12-23 15:45:20 +08:00
halx99
909b3b65f1 Add length field for name & value 2021-12-23 15:13:59 +08:00
halx99
bd0fd02860 Delete unused 2021-09-30 14:39:01 +08:00
halx99
15cec5f982 Fix logic 2021-09-30 14:36:42 +08:00
halx99
366113e72e Make logic more clearly 2021-09-30 13:27:39 +08:00
halx99
0d9a303991 Add shallow_copy support for improve performance of literal string 2021-09-30 13:00:58 +08:00
halx99
4852708894
Fix for non-cpp11 compiler 2021-09-30 11:42:35 +08:00
halx99
dbced76d85
Update pugixml.hpp 2021-09-30 11:30:17 +08:00
halx99
bffbcfddd3
Fix for non-cpp11 compiler 2021-09-30 08:46:06 +08:00
halx99
e3af24413d
Fix for non-cpp11 compiler 2021-09-30 08:26:45 +08:00
halx99
fd795fdf64 Avoid unnecessary strlen operations 2021-09-29 17:01:12 +08:00
halx99
4ed7a7f746
Fix compile issue for compiler without cpp11 2021-09-29 16:48:25 +08:00
halx99
5f1eb20568 Fix appveyor msvc120 compile error 2021-09-29 15:19:22 +08:00
halx99
b79d5806cc Use basic_string_view<char_t> instead of string_view 2021-09-29 14:56:23 +08:00
halx99
aeda2eff24 Use string_view when needs store 2021-09-29 11:47:05 +08:00
halx99
3a975d2f8e Add explicit boolean type for store as 'true' or 'false' 2021-09-29 11:21:31 +08:00
halx99
15697a7b86 Initial string_view for set_name, set_value 2021-09-29 10:37:52 +08:00
Arseny Kapoulkine
8cece4b9fe Fix a bug in move construction when move source is empty
Previously when copying the allocator state we would copy an incorrect
root pointer into the document's current state; while this had a minimal
impact on the allocation state due to the fact that any new allocation
would need to create a new page, this used a potentially stale field of
the moved document when setting up new pages, which could create issues
in future uses of the pages.

This change fixes the core problem and also removes the use of the
_root->allocator from allocate_page since it's not clear why we need it
there in the first place.
2021-05-11 22:53:54 -07:00
Arseny Kapoulkine
56c9afa7c8 XPath: Improve recursion limit for deep chains of //
Since foo//bar//baz adds two nodes for each //, we need to increment the
depth by 2 on each iteration to limit the AST correctly.

Fixes the stack overflow found by cluster-fuzz (I suspect the issue
there is a bit deeper, but this part is definitely a bug and as such I'd
rather wait for the next test case for now).
2021-05-11 22:27:53 -07:00
Rosen Penev
c167259e60 add empty method
Simple and allows to avoid using std::distance.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-04-27 13:55:02 -07:00
Rosen Penev
ef257796db remove const from operator++/--
This prevents usage with C++20 ranges since it does not satisfy
std::weakly_incrementable.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-04-26 14:06:19 -07:00
Arseny Kapoulkine
fe4bc946b2 Update copyright year to 2020 everywhere 2020-11-26 01:00:27 -08:00
Arseny Kapoulkine
70bd6a6b0a Update version to 1.11 and update documentation 2020-11-25 10:18:42 -08:00
Arseny Kapoulkine
5f97d5d66f Fix -Wshadow in remove_children()
child variable was shadowing xml_node::child
2020-11-25 09:28:26 -08:00
Arseny Kapoulkine
28aebf2b22
Merge pull request #382 from zeux/TheNicker-master
Fix MSVC deprecation warnings when using clang-cl
2020-11-25 09:19:24 -08:00
Arseny Kapoulkine
df42668e18 Cleanup code and feature detection
We now use open_file similarly to open_file_wide, and activate the
workaround for MSVC 2005+ since that's when the _s versions were added
in the first place.
2020-11-25 08:38:22 -08:00
Arseny Kapoulkine
8e5b8e0f46 XPath: Fix stack overflow in functions with long argument lists
Function call arguments are stored in a list which is processed
recursively during optimize(). We now limit the depth of this construct
as well to make sure optimize() doesn't run out of stack space.
2020-09-11 09:50:41 -07:00
Arseny Kapoulkine
20aef1cd4b Fix stack overflow in tests on MSVC x64
The default stack on MSVC/x64/debug is sufficient for 1692 nested
invocations only, whereas on clang/linux it's ~8K...

For now set the limit to be conservative.
2020-09-10 09:11:46 -07:00
Arseny Kapoulkine
1f84db837b XPath: Restrict AST depth to prevent stack overflow
XPath parser and execution engine isn't stackless; the depth of the
query controls the amount of C stack space required.

This change instruments places in the parser where the control flow can
recurse, requiring too much C stack space to produce an AST, or where a
stackless parse is used to produce arbitrarily deep AST which will
create issues for downstream processing.

As a result XPath parser should now be fuzz safe for malicious inputs.
2020-09-10 00:55:26 -07:00
Lior Lahav
c258fba6f1 Replaced fopen and _wfopen deprecated functions with the safer fopen_s and _wfopen_s 2020-07-21 22:37:16 +03:00
Arseny Kapoulkine
23ca940487 Work around a false positive in MSVC debug runtime checker
In some MSVC versions on x64 configurations, the hashing function
triggers this failure:

Run-Time Check Failure #1 - A cast to a smaller data type has caused a
loss of data.  If this was intentional, you should mask the source of
the cast with the appropriate bitmask.

This is similar to the integer sanitizer - this code is valid C++ but
MSVC decides to warn about this nonetheless. Masking the pointer's low
32 bits fixes the issue.

Fixes #357.
2020-06-13 08:41:22 -07:00
Jan Niklas Hasse
c2d90c49f9 Use nullptr in pugixml.hpp if available, see #91 2020-05-10 17:28:30 +02:00
Arseny Kapoulkine
5e64076af9 Adjust node_copy_tree to be more explicit about invariants
The loop traverses the source tree and simultaneously builds up a copy
of it at destination. Short of race conditions, this code is safe -
however, it's not obvious that dit stays inside the destination tree.

This change adds a few assertions to help enforce/document these
invariants. One particular subtlety is that dit can actually *become*
null after we exit out of the loop, but it's guaranteed to only do so
once sit goes back to sn.

This is only possible when doing a full document copy - for some reason
we weren't using this for that (in reset(xml_document)), but we are now.

Fixes #314.
2020-02-19 21:02:33 -08:00