Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

1
vendor/roxmltree/.cargo-checksum.json vendored Normal file

File diff suppressed because one or more lines are too long

312
vendor/roxmltree/CHANGELOG.md vendored Normal file
View File

@@ -0,0 +1,312 @@
# Change Log
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
## [0.20.0] - 2024-05-23
### Added
- `Attribute::range`, `Attribute::range_qname`, `Attribute::range_value`.
Thanks to [@Jayonas](https://github.com/Jayonas)
### Changed
- `Attribute::position` is deprecated now.
- The `positions` build feature uses a bit more memory now to better preserve attribute ranges.
## [0.19.0] - 2023-11-18
### Changed
- `xmlparser` is no longer a dependency and its fork is used internally.
- ~5% faster parsing.
- Fallback to `Rc` when `Arc` isn't available.
- Bump MSRV to 1.60
- Bump edition to 2021
- `Error` variants have changed quite a lot.
- XML declaration validation was simplified. We no longer check for attributes content.
Meaning that `version`, `encoding` and `standalone` can contain any value now.
But we still do check attribute names and order.<br/>
And while we did validated those attributes before, they weren't really affecting
the parser in any way. Therefore the parsing behavior is mostly unchanged.
### Fixed
- `ParsingOptions::allow_dtd = false` would not trigger an error when an empty DTD was present.
### Removed
- The `xmlparser` dependency.
## [0.18.1] - 2023-09-30
### Added
- `ExpandedName::from_static`.
Thanks to [@WhyNotHugo](https://github.com/WhyNotHugo)
### Fixed
- Replace `\r` in CDATA as well.
- `no_std` build.
Thanks to [@wenyuzhao](https://github.com/wenyuzhao)
## [0.18.0] - 2023-02-04
### Added
- `StringStorage` that exposes an internal string storage.
- Allocated strings are stored as `Arc<str>` and not `String` now.
- `Node::text_storage`
- `Node::tail_storage`
- `Attribute::value_storage`
- `Node::range`
### Removed
- `Node::position`. Use `Node::range` instead.
### Fixed
- Some methods return longer lifetimes now.
Thanks to [@adamreichold](https://github.com/adamreichold)
- Overly verbose Debug implementations.
Thanks to [@adamreichold](https://github.com/adamreichold)
## [0.17.0] - 2023-01-06
### Added
- Stored namespaces are deduplicated now, which can reduce memory usage on large files up to 10%.
Thanks to [@adamreichold](https://github.com/adamreichold)
### Changed
- `Node::namespaces` returns an iterator and not a slice now.
### Fixed
- Unclosed root element is an error now.
Thanks to [@adamreichold](https://github.com/adamreichold)
## [0.16.0] - 2022-11-20
### Added
- `positions` build feature.
- `Node::position`
- `Attribute::position`
- `ParsingOptions::nodes_limit` to limit the maximum number of nodes to parse.
### Changed
- Peak memory usage reduces by up to 20% depending on an input.
Thanks to [@adamreichold](https://github.com/adamreichold)
and [@tomjw64](https://github.com/tomjw64).
- `Node::attributes` returns an iterator and not a slice now.
### Removed
- 4GB input limit.
- Do not store Node and Attribute end range in the original document.
- Do not store attribute value range in the original document.
- `Node::range`. Use `position` instead.
- `Attribute::range`. Use `position` instead.
- `Attribute::value_range`
## [0.15.1] - 2022-10-18
### Fixed
- Bump `xmlparser` to prevent stack overflow on some input.
## [0.15.0] - 2022-08-15
### Changed
- Extend `Document::descendants` lifetime.
Thanks to [@DBLouis](https://github.com/DBLouis).
- Derive `Eq` and `Hash` for `NodeId`.
- Remove `pretty_assertions` dev-dependency.
- MSRV is now 1.36
## [0.14.1] - 2021-04-01
### Changed
- The `std` feature is enabled by default now.
## [0.14.0] - 2020-12-27
### Added
- An ability to reject XML with DTD in it.
- The library is no_std + alloc now.
- `ParsingOptions`
- `Document::parse_with_options`
- `Error::DtdDetected`
## [0.13.1] - 2020-12-19
### Added
- `Debug` for all public types.
## [0.13.0] - 2020-06-20
### Changed
- Better `ExpandedName` lifetimes. Thanks to [@eduardosm](https://github.com/eduardosm).
## [0.12.0] - 2020-06-20
### Changed
- Re-release 0.11.1, since it had a breaking change.
## [0.11.1] - 2020-06-19
### Changed
- Extend `ExpandedName` lifetime. Thanks to [@rkusa](https://github.com/rkusa).
## [0.11.0] - 2020-04-19
### Added
- Implement `Ord`, `PartialOrd` and `Hash` for `Node`. Thanks to [@tomjw64].
- `NodeId`, `Document::get_node` and `Node::id`. Thanks to [@tomjw64].
### Changed
- The input data size is limited by 4GiB now.
- `Node` can be accessed from multiple threads now.
- Reduce `Node` memory usage.
- Greatly optimized `Descendants` iterator. Up to 5x faster in some cases. Thanks to [@tomjw64].
- Heavily reduce memory usage when document has a lot of namespaces. Thanks to [@tomjw64].
### Removed
- `Node::traverse`, `Traverse` and `Edge`. Use `Node::descendants` instead.
## [0.10.1] - 2020-03-28
### Fixed
- `Node::prev_sibling_element` and `Node::next_sibling_element`
were returning the current node.
## [0.10.0] - 2020-03-18
### Added
- `Document::input_text`
### Changed
- `Ancestors`, `PrevSiblings`, `NextSiblings`, `FirstChildren` and `LastChildren`
were replaced with `AxisIter`.
### Fixed
- Root node range.
## [0.9.1] - 2020-02-09
### Changed
- A better entity loop detection. A document can have an unlimited
number of references at zero depth now.
## [0.9.0] - 2020-01-07
### Changed
- Moved to Rust 2018.
- `xmlparser` updated.
## [0.8.0] - 2019-12-21
### Added
- `Error::MalformedEntityReference`
### Changed
- Malformed entity reference is an error now.
- Escaped `<` in attribute inside an ENTITY is an error now.
- `xmlparser` updated with multiple fixes.
## [0.7.3] - 2019-11-14
### Changed
- Use unconstrained lifetimes for the `attribute` functions.
By [myrrlyn](https://github.com/myrrlyn).
## [0.7.2] - 2019-11-07
### Changed
- Use longer lifetimes in `Document::root_element`.
By [myrrlyn](https://github.com/myrrlyn).
## [0.7.1] - 2019-09-14
### Changed
- Update `xmlparser`.
## [0.7.0] - 2019-08-06
### Added
- `Node::prev_sibling_element` and `Node::next_sibling_element`.
### Changed
- **(breaking)** `Node::ancestors` includes the current node now.
- `Attribute` is cloneable now.
### Fixed
- Namespaces resolving with equal URI's.
### Removed
- `Node::resolve_tag_name_prefix`.
## [0.6.1] - 2019-06-18
### Fixed
- Namespace resolving.
## [0.6.0] - 2019-03-03
### Added
- `Error::UnknownNamespace`.
### Fixed
- Unknown namespace prefixes will cause an error now.
## [0.5.0] - 2019-02-27
### Added
- `Node::range`.
- `Node::attribute_node`.
- `Attribute::range`.
- `Attribute::value_range`.
### Changed
- Rename `text_pos_from` into `text_pos_at`.
### Removed
- `Node::pos`. Use `Node::range` instead.
- `Node::node_pos`. Use `doc.text_pos_at(node.range().start)` instead.
- `Node::attribute_pos`.
- `Node::attribute_value_pos`.
- `Attribute::pos`. Use `Attribute::range` instead.
- `Attribute::value_pos`. Use `Attribute::value_range` instead.
## [0.4.1] - 2019-01-02
### Changed
- Use longer lifetimes in return types. By [tmiasko](https://github.com/tmiasko).
## [0.4.0] - 2018-12-13
### Added
- `Error::pos()`.
## [0.3.0] - 2018-10-29
### Changed
- Store text nodes as `&str` when possible. On an XML with a lot of simple text can be ~2x faster.
- `Document` no longer implements `PartialEq`.
### Fixed
- Entity and character references resolving inside a text.
## [0.2.0] - 2018-10-08
### Added
- `Error::EntityReferenceLoop`.
- Nested entity references support.
### Changed
- `Attribute::namespace` will return `Option` now.
- `ExpandedName::namespace` will return `Option` now.
- `Namespace::name` will return `Option` now.
- `Node::resolve_tag_name_prefix` will return `Option` now.
- `Node::lookup_namespace_uri` accepts `Option<&str>` and not `&str` now.
- Performance optimizations.
### Removed
- `ExpandedName::has_namespace`. `ExpandedName::namespace` will return `Option` now.
- `Error::NestedEntityReference`.
[@tomjw64]: https://github.com/tomjw64
[Unreleased]: https://github.com/RazrFalcon/roxmltree/compare/v0.20.0..HEAD
[0.20.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.19.0...v0.20.0
[0.19.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.18.1...v0.19.0
[0.18.1]: https://github.com/RazrFalcon/roxmltree/compare/v0.18.0...v0.18.1
[0.18.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.17.0...v0.18.0
[0.17.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.16.0...v0.17.0
[0.16.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.15.1...v0.16.0
[0.15.1]: https://github.com/RazrFalcon/roxmltree/compare/v0.15.0...v0.15.1
[0.15.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.14.1...v0.15.0
[0.14.1]: https://github.com/RazrFalcon/roxmltree/compare/v0.14.0...v0.14.1
[0.14.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.13.1...v0.14.0
[0.13.1]: https://github.com/RazrFalcon/roxmltree/compare/v0.13.0...v0.13.1
[0.13.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.12.0...v0.13.0
[0.12.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.11.1...v0.12.0
[0.11.1]: https://github.com/RazrFalcon/roxmltree/compare/v0.11.0...v0.11.1
[0.11.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.10.1...v0.11.0
[0.10.1]: https://github.com/RazrFalcon/roxmltree/compare/v0.10.0...v0.10.1
[0.10.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.9.1...v0.10.0
[0.9.1]: https://github.com/RazrFalcon/roxmltree/compare/v0.9.0...v0.9.1
[0.9.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.8.0...v0.9.0
[0.8.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.7.3...v0.8.0
[0.7.3]: https://github.com/RazrFalcon/roxmltree/compare/v0.7.2...v0.7.3
[0.7.2]: https://github.com/RazrFalcon/roxmltree/compare/v0.7.1...v0.7.2
[0.7.1]: https://github.com/RazrFalcon/roxmltree/compare/v0.7.0...v0.7.1
[0.7.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.6.1...v0.7.0
[0.6.1]: https://github.com/RazrFalcon/roxmltree/compare/v0.6.0...v0.6.1
[0.6.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.5.0...v0.6.0
[0.5.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.4.1...v0.5.0
[0.4.1]: https://github.com/RazrFalcon/roxmltree/compare/v0.4.0...v0.4.1
[0.4.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/RazrFalcon/roxmltree/compare/v0.1.0...v0.2.0

7
vendor/roxmltree/Cargo.lock generated vendored Normal file
View File

@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "roxmltree"
version = "0.20.0"

37
vendor/roxmltree/Cargo.toml vendored Normal file
View File

@@ -0,0 +1,37 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2021"
rust-version = "1.60"
name = "roxmltree"
version = "0.20.0"
authors = ["Yevhenii Reizner <razrfalcon@gmail.com>"]
description = "Represent an XML as a read-only tree."
documentation = "https://docs.rs/roxmltree/"
readme = "README.md"
keywords = [
"xml",
"parser",
"tree",
"dom",
]
categories = ["parser-implementations"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/RazrFalcon/roxmltree"
[features]
default = [
"std",
"positions",
]
positions = []
std = []

201
vendor/roxmltree/LICENSE-APACHE vendored Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

21
vendor/roxmltree/LICENSE-MIT vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018 Yevhenii Reizner
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

179
vendor/roxmltree/README.md vendored Normal file
View File

@@ -0,0 +1,179 @@
# roxmltree
![Build Status](https://github.com/RazrFalcon/roxmltree/workflows/Rust/badge.svg)
[![Crates.io](https://img.shields.io/crates/v/roxmltree.svg)](https://crates.io/crates/roxmltree)
[![Documentation](https://docs.rs/roxmltree/badge.svg)](https://docs.rs/roxmltree)
[![Rust 1.60+](https://img.shields.io/badge/rust-1.60+-orange.svg)](https://www.rust-lang.org)
Represents an [XML](https://www.w3.org/TR/xml/) document as a read-only tree.
```rust
// Find element by id.
let doc = roxmltree::Document::parse("<rect id='rect1'/>")?;
let elem = doc.descendants().find(|n| n.attribute("id") == Some("rect1"))?;
assert!(elem.has_tag_name("rect"));
```
## Why read-only?
Because in some cases all you need is to retrieve some data from an XML document.
And for such cases, we can make a lot of optimizations.
## Parsing behavior
Sadly, XML can be parsed in many different ways. *roxmltree* tries to mimic the
behavior of Python's [lxml](https://lxml.de/).
For more details see [docs/parsing.md](https://github.com/RazrFalcon/roxmltree/blob/master/docs/parsing.md).
## Alternatives
| Feature/Crate | roxmltree | [libxml2] | [xmltree] | [sxd-document] |
| ------------------------------- | :--------------: | :-----------------: | :--------------: | :--------------: |
| Element namespace resolving | ✓ | ✓ | ✓ | ~<sup>1</sup> |
| Attribute namespace resolving | ✓ | ✓ | | ✓ |
| [Entity references] | ✓ | ✓ | × | × |
| [Character references] | ✓ | ✓ | ✓ | ✓ |
| [Attribute-Value normalization] | ✓ | ✓ | | |
| Comments | ✓ | ✓ | | ✓ |
| Processing instructions | ✓ | ✓ | ✓ | ✓ |
| UTF-8 BOM | ✓ | ✓ | × | × |
| Non UTF-8 input | | ✓ | | |
| Complete DTD support | | ✓ | | |
| Position preserving<sup>2</sup> | ✓ | ✓ | | |
| HTML support | | ✓ | | |
| Tree modification | | ✓ | ✓ | ✓ |
| Writing | | ✓ | ✓ | ✓ |
| No **unsafe** | ✓ | | ✓ | |
| Language | Rust | C | Rust | Rust |
| Dependencies | **0** | - | 2 | 2 |
| Tested version | 0.20.0 | Apple-provided | 0.10.3 | 0.3.2 |
| License | MIT / Apache-2.0 | MIT | MIT | MIT |
Legend:
- ✓ - supported
- × - parsing error
- ~ - partial
- *nothing* - not supported
Notes:
1. No default namespace propagation.
2. *roxmltree* keeps all node and attribute positions in the original document,
so you can easily retrieve it if you need it.
See [examples/print_pos.rs](examples/print_pos.rs) for details.
There is also `elementtree` and `treexml` crates, but they are abandoned for a long time.
[Entity references]: https://www.w3.org/TR/REC-xml/#dt-entref
[Character references]: https://www.w3.org/TR/REC-xml/#NT-CharRef
[Attribute-Value Normalization]: https://www.w3.org/TR/REC-xml/#AVNormalize
[libxml2]: http://xmlsoft.org/
[xmltree]: https://crates.io/crates/xmltree
[sxd-document]: https://crates.io/crates/sxd-document
## Performance
Here are some benchmarks comparing `roxmltree` to other XML tree libraries.
```text
test huge_roxmltree ... bench: 2,997,887 ns/iter (+/- 48,976)
test huge_libxml2 ... bench: 6,850,666 ns/iter (+/- 306,180)
test huge_sdx_document ... bench: 9,440,412 ns/iter (+/- 117,106)
test huge_xmltree ... bench: 41,662,316 ns/iter (+/- 850,360)
test large_roxmltree ... bench: 1,494,886 ns/iter (+/- 30,384)
test large_libxml2 ... bench: 3,250,606 ns/iter (+/- 140,201)
test large_sdx_document ... bench: 4,242,162 ns/iter (+/- 99,740)
test large_xmltree ... bench: 13,980,228 ns/iter (+/- 229,363)
test medium_roxmltree ... bench: 421,137 ns/iter (+/- 13,855)
test medium_libxml2 ... bench: 950,984 ns/iter (+/- 34,099)
test medium_sdx_document ... bench: 1,618,270 ns/iter (+/- 23,466)
test medium_xmltree ... bench: 4,315,974 ns/iter (+/- 31,849)
test tiny_roxmltree ... bench: 2,522 ns/iter (+/- 31)
test tiny_libxml2 ... bench: 8,931 ns/iter (+/- 235)
test tiny_sdx_document ... bench: 11,658 ns/iter (+/- 82)
test tiny_xmltree ... bench: 20,215 ns/iter (+/- 303)
```
When comparing to streaming XML parsers `roxmltree` is slightly slower than `quick-xml`,
but still way faster than `xmlrs`.
Note that streaming parsers usually do not provide a proper string unescaping,
DTD resolving and namespaces support.
```text
test huge_quick_xml ... bench: 2,997,887 ns/iter (+/- 48,976)
test huge_roxmltree ... bench: 3,147,424 ns/iter (+/- 49,153)
test huge_xmlrs ... bench: 36,258,312 ns/iter (+/- 180,438)
test large_quick_xml ... bench: 1,250,053 ns/iter (+/- 21,943)
test large_roxmltree ... bench: 1,494,886 ns/iter (+/- 30,384)
test large_xmlrs ... bench: 11,239,516 ns/iter (+/- 76,937)
test medium_quick_xml ... bench: 206,232 ns/iter (+/- 2,157)
test medium_roxmltree ... bench: 421,137 ns/iter (+/- 13,855)
test medium_xmlrs ... bench: 3,975,916 ns/iter (+/- 44,967)
test tiny_quick_xml ... bench: 2,233 ns/iter (+/- 70)
test tiny_roxmltree ... bench: 2,522 ns/iter (+/- 31)
test tiny_xmlrs ... bench: 17,155 ns/iter (+/- 429)
```
### Notes
The benchmarks were taken on a Apple M1 Pro.
You can try running the benchmarks yourself by running `cargo bench` in the `benches` dir.
- Since all libraries have a different XML support, benchmarking is a bit pointless.
- We bench *libxml2* using the *[rust-libxml]* wrapper crate
[xml-rs]: https://crates.io/crates/xml-rs
[quick-xml]: https://crates.io/crates/quick-xml
[rust-libxml]: https://github.com/KWARC/rust-libxml
## Memory overhead
`roxmltree` tries to use as little memory as possible to allow parsing
very large (multi-GB) XML files.
The peak memory usage doesn't directly correlate with the file size
but rather with the amount of nodes and attributes a file has.
How many attributes had to be normalized (i.e. allocated).
And how many text nodes had to be preprocessed (i.e. allocated).
`roxmltree` never allocates element and attribute names, processing instructions
and comments.
By disabling the `positions` feature, you can shave 8 bytes from each node and attribute.
On average, the overhead is around 6-8x the file size.
For example, our 1.1GB sample XML will peak at 7.6GB RAM with default features enabled
and at 6.8GB RAM when `positions` is disabled.
## Safety
- This library must not panic. Any panic should be considered a critical bug and reported.
- This library forbids `unsafe` code.
## API
This library uses Rust's idiomatic API based on iterators.
In case you are more familiar with browser/JS DOM APIs - you can check out
[tests/dom-api.rs](tests/dom-api.rs) to see how it can be mapped onto the Rust one.
## License
Licensed under either of
- [Apache License v2.0](LICENSE-APACHE)
- [MIT license](LICENSE-MIT)
at your option.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.

101
vendor/roxmltree/docs/parsing.md vendored Normal file
View File

@@ -0,0 +1,101 @@
# roxmltree parsing strategy
XML parsing is hard. Everyone knows that. But the other problem is that it
can be represented in very different ways:
- You can preserve comment or ignore them completely or partially.
- You can represent text data as a separated node or embed it into the element node.
- You can keep CDATA as a separated node or merge it into the text node.
- You can preserve XML declaration or ignore it completely.
- ... and many more.
This document explains how *roxmltree* parses and represents the XML document.
## XML declaration
[XML declaration](https://www.w3.org/TR/xml/#NT-XMLDecl) is completely ignored.
Mostly because it doesn't contain any valuable information for us.
- `version` is expected to be `1.*`. Otherwise an error will occur.
- `encoding` is irrelevant since we are parsing only valid UTF-8 strings.
- And no one really follow the `standalone` constraints.
## DTD
Only `ENTITY` objects will be resolved. Everything else will be ignored
at the moment.
```xml
<!DOCTYPE test [
<!ENTITY a 'text<p/>text'>
]>
<e>&a;</e>
```
will be parsed into:
```xml
<e>text<p/>text</e>
```
Were `p` is an element, not a text.
## Comments
All comment will be preserved.
## Processing instructions
All processing instructions will be preserved.
## Whitespaces
All whitespaces inside the root element will be preserved.
```xml
<p>
text
</p>
```
it will be parsed as `\n␣␣␣␣text\n`.
Same goes to an escaped one:
```xml
<p>&#x20;&#x20;text&#x20;&#x20;</p>
```
it will be parsed as `␣␣text␣␣`.
## CDATA
CDATA will be embedded to a text node:
```xml
<p>t<![CDATA[e&#x20;]]>&#x20;x<![CDATA[t]]></p>
```
it will be parsed as `te&#x20; xt`.
## Text
Text will be unescaped. All entity references will be resolved.
```xml
<!DOCTYPE test [
<!ENTITY b 'Some&#x20;text'>
]>
<p>&b;</p>
```
it will be parsed as `Some text`.
## Attribute-Value Normalization
[Attribute-Value Normalization](https://www.w3.org/TR/xml/#AVNormalize) works
as explained in the spec.
## Namespaces resolving
*roxmltree* has a complete support for XML namespaces.

19
vendor/roxmltree/examples/ast.rs vendored Normal file
View File

@@ -0,0 +1,19 @@
fn main() {
let args: Vec<_> = std::env::args().collect();
if args.len() != 2 {
println!("Usage:\n\tcargo run --example ast -- input.xml");
std::process::exit(1);
}
let text = std::fs::read_to_string(&args[1]).unwrap();
let opt = roxmltree::ParsingOptions {
allow_dtd: true,
..roxmltree::ParsingOptions::default()
};
match roxmltree::Document::parse_with_options(&text, opt) {
Ok(doc) => print!("{:?}", doc),
Err(e) => println!("Error: {}.", e),
}
}

36
vendor/roxmltree/examples/print_pos.rs vendored Normal file
View File

@@ -0,0 +1,36 @@
#[cfg(feature = "positions")]
fn main() {
let args: Vec<_> = std::env::args().collect();
if args.len() != 2 {
println!("Usage:\n\tcargo run --example print_pos -- input.xml");
std::process::exit(1);
}
let text = std::fs::read_to_string(&args[1]).unwrap();
let opt = roxmltree::ParsingOptions {
allow_dtd: true,
..roxmltree::ParsingOptions::default()
};
let doc = match roxmltree::Document::parse_with_options(&text, opt) {
Ok(doc) => doc,
Err(e) => {
println!("Error: {}.", e);
return;
}
};
// TODO: finish
for node in doc.descendants() {
if node.is_element() {
println!(
"{:?} at {}",
node.tag_name(),
doc.text_pos_at(node.range().start)
);
}
}
}
#[cfg(not(feature = "positions"))]
fn main() {}

61
vendor/roxmltree/examples/stats.rs vendored Normal file
View File

@@ -0,0 +1,61 @@
use std::collections::HashSet;
fn main() {
let args: Vec<_> = std::env::args().collect();
if args.len() != 2 {
println!("Usage:\n\tcargo run --example stats -- input.xml");
std::process::exit(1);
}
let text = std::fs::read_to_string(&args[1]).unwrap();
let opt = roxmltree::ParsingOptions {
allow_dtd: true,
..roxmltree::ParsingOptions::default()
};
let doc = match roxmltree::Document::parse_with_options(&text, opt) {
Ok(v) => v,
Err(e) => {
println!("Error: {}.", e);
std::process::exit(1);
}
};
println!(
"Elements count: {}",
doc.root().descendants().filter(|n| n.is_element()).count()
);
let attrs_count: usize = doc.root().descendants().map(|n| n.attributes().len()).sum();
println!("Attributes count: {}", attrs_count);
let ns_count: usize = doc.root().descendants().map(|n| n.namespaces().len()).sum();
println!("Namespaces count: {}", ns_count);
let mut uris = HashSet::new();
for node in doc.root().descendants() {
for ns in node.namespaces() {
uris.insert((
ns.name().unwrap_or("\"\"").to_string(),
ns.uri().to_string(),
));
}
}
println!("Unique namespaces count: {}", uris.len());
if !uris.is_empty() {
println!("Unique namespaces:");
for (key, value) in uris {
println!(" {:?}: {}", key, value);
}
}
println!(
"Comments count: {}",
doc.root().descendants().filter(|n| n.is_comment()).count()
);
println!("Comments:");
for node in doc.root().descendants().filter(|n| n.is_comment()) {
println!("{:?}", node.text().unwrap());
}
}

1746
vendor/roxmltree/src/lib.rs vendored Normal file

File diff suppressed because it is too large Load Diff

1334
vendor/roxmltree/src/parse.rs vendored Normal file

File diff suppressed because it is too large Load Diff

1112
vendor/roxmltree/src/tokenizer.rs vendored Normal file

File diff suppressed because it is too large Load Diff

1014
vendor/roxmltree/src/tokenizer_tests.rs vendored Normal file

File diff suppressed because it is too large Load Diff

104
vendor/roxmltree/testing-tools/lxml-ast.py vendored Executable file
View File

@@ -0,0 +1,104 @@
#!/usr/bin/env python3
import sys
from lxml import etree
def escape_text(text):
return text.encode('unicode_escape').decode("utf-8")
def split_qname(name):
if name[0] == '{':
return name[1:].split('}')
else:
return [None, name]
def print_ind(depth, *args, **kwargs):
indent = ' ' * depth
indent = indent[:-1]
print(indent, *args, **kwargs)
def print_node(node, depth):
if node.tag is etree.Comment:
print_ind(depth, '- Comment: "{}"'.format(escape_text(node.text)))
if node.tail:
print_ind(depth, '- Text: "{}"'.format(escape_text(node.tail)))
return
if node.tag is etree.PI:
print_ind(depth, '- PI:')
print_ind(depth + 2, 'target: "{}"'.format(node.target))
print_ind(depth + 2, 'value: "{}"'.format(escape_text(node.text)))
if node.tail:
print_ind(depth, '- Text: "{}"'.format(escape_text(node.tail)))
return
print_ind(depth, '- Element:')
if node.tag[0] == '{':
uri, tag = split_qname(node.tag)
print_ind(depth + 2, 'tag_name: {}@{}'.format(tag, uri))
else:
print_ind(depth + 2, 'tag_name:', node.tag)
if node.attrib:
print_ind(depth + 2, 'attributes:')
attrs = []
for name, value in node.attrib.items():
uri, tag = split_qname(name)
if uri:
attrs.append([tag + '@' + uri, value])
else:
attrs.append([tag, value])
attrs = sorted(attrs, key=lambda x: x[0])
for name, value in attrs:
print_ind(depth + 3, '{}: "{}"'.format(name, escape_text(value)))
if node.nsmap:
print_ind(depth + 2, 'namespaces:')
ns_list = []
for name, value in node.nsmap.items():
if not name and not value:
ns_list.append(['None', '""'])
elif not name:
ns_list.append(['None', value])
elif not value:
ns_list.append([name, '""'])
else:
ns_list.append([name, value])
ns_list = sorted(ns_list, key=lambda x: x[0])
for name, value in ns_list:
print_ind(depth + 3, '{}: {}'.format(name, value))
if len(node):
print_ind(depth + 2, 'children:')
if node.text:
print_ind(depth + 3, '- Text: "{}"'.format(escape_text(node.text)))
for child in node:
print_node(child, depth + 3)
elif node.text:
print_ind(depth + 2, 'children:')
print_ind(depth + 3, '- Text: "{}"'.format(escape_text(node.text)))
if node.tail:
print_ind(depth, '- Text: "{}"'.format(escape_text(node.tail)))
tree = etree.parse(sys.argv[1])
root = tree.getroot()
print('Document:')
print_node(root, 1)

51
vendor/roxmltree/testing-tools/test-lxml.py vendored Executable file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env python3
import os
import subprocess
import fnmatch
from pathlib import Path
ignore = [
"comments_001.xml",
"tree_001.xml",
]
input_dir = '../tests/files/'
files = os.listdir(input_dir)
files = fnmatch.filter(files, '*.xml')
files = sorted(files)
is_ok = True
for idx, xml_file_name in enumerate(files):
xml_file_path = input_dir + xml_file_name
res_file_path = input_dir + Path(input_dir + xml_file_name).stem + '.yaml'
print('Test {} of {}: {}'.format(idx + 1, len(files), xml_file_name))
if xml_file_name in ignore:
continue
with open(res_file_path, 'r') as f:
expected_ast = f.read()
try:
lxml_ast = subprocess.check_output(['./lxml-ast.py', xml_file_path],
stderr=subprocess.DEVNULL).decode('utf-8')
except subprocess.CalledProcessError as e:
if expected_ast.startswith('error:'):
continue
else:
is_ok = False
print('Failed')
break
if lxml_ast != expected_ast:
is_ok = False
print('Failed')
break
if not is_ok:
exit(1)

358
vendor/roxmltree/tests/api.rs vendored Normal file
View File

@@ -0,0 +1,358 @@
#![allow(clippy::bool_assert_comparison)]
use roxmltree::*;
#[test]
fn error_size() {
assert!(::std::mem::size_of::<Error>() <= 64);
}
#[test]
fn root_element_01() {
let data = "\
<!-- comment -->
<e/>
";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
assert_eq!(node.tag_name().name(), "e");
}
#[test]
fn get_text_01() {
let data = "\
<root>
Text1
<item>
Text2
</item>
Text3
</root>
";
let doc = Document::parse(data).unwrap();
let root = doc.root_element();
assert_eq!(root.text(), Some("\n Text1\n "));
assert_eq!(root.tail(), None);
let item = root.children().nth(1).unwrap();
assert_eq!(item.text(), Some("\n Text2\n "));
assert_eq!(item.tail(), Some("\n Text3\n"));
}
#[test]
fn get_text_02() {
let data = "<root>&apos;</root>";
let doc = Document::parse(data).unwrap();
let root = doc.root_element();
assert_eq!(root.text(), Some("'"));
}
#[test]
fn api_01() {
let data = "\
<e a:attr='a_ns' b:attr='b_ns' attr='no_ns' xmlns:b='http://www.ietf.org' \
xmlns:a='http://www.w3.org' xmlns='http://www.uvic.ca'/>
";
let doc = Document::parse(data).unwrap();
let p = doc.root_element();
assert_eq!(p.attribute("attr"), Some("no_ns"));
assert_eq!(p.has_attribute("attr"), true);
assert_eq!(p.attribute(("http://www.w3.org", "attr")), Some("a_ns"));
assert_eq!(p.has_attribute(("http://www.w3.org", "attr")), true);
assert_eq!(p.attribute("attr2"), None);
assert_eq!(p.has_attribute("attr2"), false);
assert_eq!(p.attribute(("http://www.w2.org", "attr")), None);
assert_eq!(p.has_attribute(("http://www.w2.org", "attr")), false);
assert_eq!(p.attribute("b"), None);
assert_eq!(p.has_attribute("b"), false);
assert_eq!(p.attribute("xmlns"), None);
assert_eq!(p.has_attribute("xmlns"), false);
}
#[test]
fn get_pi() {
let data = "\
<?target value?>
<root/>
";
let doc = Document::parse(data).unwrap();
let node = doc.root().first_child().unwrap();
assert_eq!(
node.pi(),
Some(PI {
target: "target",
value: Some("value")
})
);
}
#[test]
fn lookup_prefix_01() {
let data = "<e xmlns:n1='http://www.w3.org' n1:a='b1'/>";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
assert_eq!(node.lookup_prefix("http://www.w3.org"), Some("n1"));
assert_eq!(node.lookup_prefix("http://www.w4.org"), None);
}
#[test]
fn lookup_prefix_02() {
let data = "<e xml:space='preserve'/>";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
assert_eq!(node.lookup_prefix(NS_XML_URI), Some("xml"));
}
#[test]
fn lookup_namespace_uri() {
let data = "<e xmlns:n1='http://www.w3.org' xmlns='http://www.w4.org'/>";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
assert_eq!(
node.lookup_namespace_uri(Some("n1")),
Some("http://www.w3.org")
);
assert_eq!(node.lookup_namespace_uri(None), Some("http://www.w4.org"));
assert_eq!(node.lookup_namespace_uri(Some("n2")), None);
}
#[cfg(feature = "positions")]
#[test]
fn text_pos_01() {
let data = "\
<e a='b'>
<!-- comment -->
<p>Text</p>
</e>
";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
assert_eq!(
doc.text_pos_at(doc.root().range().start),
TextPos::new(1, 1)
);
assert_eq!(doc.text_pos_at(doc.root().range().end), TextPos::new(5, 1));
assert_eq!(doc.text_pos_at(node.range().start), TextPos::new(1, 1));
assert_eq!(doc.text_pos_at(node.range().end), TextPos::new(4, 5));
if let Some(attr) = node.attribute_node("a") {
assert_eq!(doc.text_pos_at(attr.range().start), TextPos::new(1, 4));
assert_eq!(doc.text_pos_at(attr.range().end), TextPos::new(1, 9));
assert_eq!(doc.text_pos_at(attr.range_qname().start), TextPos::new(1, 4));
assert_eq!(doc.text_pos_at(attr.range_qname().end), TextPos::new(1, 5));
assert_eq!(doc.text_pos_at(attr.range_value().start), TextPos::new(1, 7));
assert_eq!(doc.text_pos_at(attr.range_value().end), TextPos::new(1, 8));
}
// first child is a text/whitespace, not a comment
let comm = node.first_child().unwrap().next_sibling().unwrap();
assert_eq!(doc.text_pos_at(comm.range().start), TextPos::new(2, 5));
let p = comm.next_sibling().unwrap().next_sibling().unwrap();
assert_eq!(doc.text_pos_at(p.range().start), TextPos::new(3, 5));
let text = p.first_child().unwrap();
assert_eq!(doc.text_pos_at(text.range().start), TextPos::new(3, 8));
}
#[cfg(feature = "positions")]
#[test]
fn text_pos_02() {
let data = "<n1:e xmlns:n1='http://www.w3.org' n1:a='b'/>";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
assert_eq!(doc.text_pos_at(node.range().start), TextPos::new(1, 1));
if let Some(attr) = node.attribute_node(("http://www.w3.org", "a")) {
assert_eq!(doc.text_pos_at(attr.range().start), TextPos::new(1, 36));
assert_eq!(doc.text_pos_at(attr.range().end), TextPos::new(1, 44));
assert_eq!(doc.text_pos_at(attr.range_qname().start), TextPos::new(1, 36));
assert_eq!(doc.text_pos_at(attr.range_qname().end), TextPos::new(1, 40));
assert_eq!(doc.text_pos_at(attr.range_value().start), TextPos::new(1, 42));
assert_eq!(doc.text_pos_at(attr.range_value().end), TextPos::new(1, 43));
}
}
#[cfg(feature = "positions")]
#[test]
fn text_pos_03() {
let data = "\
<!-- comment -->
<e/>
";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
assert_eq!(doc.text_pos_at(node.range().start), TextPos::new(2, 1));
assert_eq!(doc.text_pos_at(node.range().end), TextPos::new(2, 5));
}
#[cfg(feature = "positions")]
#[test]
fn text_pos_04() {
let data = "<n1:e xmlns:n1='http://www.w3.org' n1:a=''/>";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
if let Some(attr) = node.attribute_node("a") {
assert_eq!(doc.text_pos_at(attr.range().start), TextPos::new(1, 36));
assert_eq!(doc.text_pos_at(attr.range().end), TextPos::new(1, 43));
assert_eq!(doc.text_pos_at(attr.range_qname().start), TextPos::new(1, 36));
assert_eq!(doc.text_pos_at(attr.range_qname().end), TextPos::new(1, 40));
assert_eq!(doc.text_pos_at(attr.range_value().start), TextPos::new(1, 42));
assert_eq!(doc.text_pos_at(attr.range_value().end), TextPos::new(1, 42));
}
}
#[cfg(feature = "positions")]
#[test]
fn text_pos_05() {
let data = "<n1:e xmlns:n1='http://www.w3.org' n1:a = 'b'/>";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
if let Some(attr) = node.attribute_node("a") {
assert_eq!(doc.text_pos_at(attr.range().start), TextPos::new(1, 36));
assert_eq!(doc.text_pos_at(attr.range().end), TextPos::new(1, 48));
assert_eq!(doc.text_pos_at(attr.range_qname().start), TextPos::new(1, 36));
assert_eq!(doc.text_pos_at(attr.range_qname().end), TextPos::new(1, 40));
assert_eq!(doc.text_pos_at(attr.range_value().start), TextPos::new(1, 47));
assert_eq!(doc.text_pos_at(attr.range_value().end), TextPos::new(1, 48));
}
}
#[cfg(feature = "positions")]
#[test]
fn text_pos_06() {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
let data = "<e a = 'b'/>";
let doc = Document::parse(data).unwrap();
let node = doc.root_element();
if let Some(attr) = node.attribute_node("a") {
assert_eq!(doc.text_pos_at(attr.range().start), TextPos::new(1, 4));
assert_eq!(doc.text_pos_at(attr.range().end), TextPos::new(1, 269));
assert_eq!(doc.text_pos_at(attr.range_qname().start), TextPos::new(1, 4));
assert_eq!(doc.text_pos_at(attr.range_qname().end), TextPos::new(1, 5));
attr.range_value(); // unreliable since >254 spaces around equal sign, but still shouldn't panic
}
}
#[test]
fn next_sibling_element_01() {
let data = "<root><a/><b/><c/></root>";
let doc = roxmltree::Document::parse(data).unwrap();
let root = doc.root_element();
let a = root.first_element_child().unwrap();
let b = a.next_sibling_element().unwrap();
let c = b.next_sibling_element().unwrap();
assert!(c.next_sibling_element().is_none());
assert_eq!(root.tag_name().name(), "root");
assert_eq!(a.tag_name().name(), "a");
assert_eq!(b.tag_name().name(), "b");
assert_eq!(c.tag_name().name(), "c");
}
#[test]
fn next_prev_element_01() {
let data = "<root><a/><b/><c/></root>";
let doc = roxmltree::Document::parse(data).unwrap();
let root = doc.root_element();
let c = root.last_element_child().unwrap();
let b = c.prev_sibling_element().unwrap();
let a = b.prev_sibling_element().unwrap();
assert!(a.prev_sibling_element().is_none());
assert_eq!(root.tag_name().name(), "root");
assert_eq!(a.tag_name().name(), "a");
assert_eq!(b.tag_name().name(), "b");
assert_eq!(c.tag_name().name(), "c");
}
#[test]
fn nodes_document_order() {
let data = "<root><a/><b/><c/></root>";
let doc = roxmltree::Document::parse(data).unwrap();
let root = doc.root_element();
let a = root.first_element_child().unwrap();
let b = a.next_sibling_element().unwrap();
let c = b.next_sibling_element().unwrap();
let mut elems = vec![&b, &c, &a];
elems.sort();
assert!(elems[0] == &a);
assert!(elems[1] == &b);
assert!(elems[2] == &c);
}
#[test]
fn lifetimes() {
fn f<'a, 'd, F, R>(doc: &'a roxmltree::Document<'d>, fun: F) -> R
where
F: Fn(&'a roxmltree::Document<'d>) -> R,
{
fun(doc)
}
let doc = roxmltree::Document::parse("<e xmlns='http://www.w3.org'/>").unwrap();
let _ = f(&doc, |d| d.root());
let _ = f(&doc, |d| d.root().document());
let _ = f(&doc, |d| d.root().tag_name());
let _ = f(&doc, |d| d.root().tag_name().namespace());
let _ = f(&doc, |d| d.root().tag_name().name());
let _ = f(&doc, |d| d.root().default_namespace());
let _ = f(&doc, |d| d.root().lookup_prefix(""));
let _ = f(&doc, |d| d.root().lookup_namespace_uri(None));
let _ = f(&doc, |d| d.root().attribute("a"));
let _ = f(&doc, |d| d.root().attribute_node("a"));
let _ = f(&doc, |d| d.root().attributes());
let _ = f(&doc, |d| d.root().namespaces());
let _ = f(&doc, |d| d.root().text());
let _ = f(&doc, |d| d.root().tail());
let _ = f(&doc, |d| d.root().pi());
}
#[test]
fn tag_name_lifetime() {
fn get_tag_name<'a, 'input>(node: &'a Node<'a, 'input>) -> &'input str {
node.tag_name().name()
}
let data = "<e xmlns='http://www.w3.org' />";
let doc = roxmltree::Document::parse(data).unwrap();
let root = doc.root_element();
assert_eq!(get_tag_name(&root), "e");
}

292
vendor/roxmltree/tests/ast.rs vendored Normal file
View File

@@ -0,0 +1,292 @@
use roxmltree::*;
use std::fmt;
use std::fmt::Write;
use std::fs;
use std::io::Read;
use std::path;
#[derive(Clone, Copy, PartialEq)]
struct TStr<'a>(pub &'a str);
impl<'a> fmt::Debug for TStr<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}
trait HasExtension {
fn has_extension(&self, ext: &str) -> bool;
}
impl HasExtension for path::Path {
fn has_extension(&self, ext: &str) -> bool {
if let Some(e) = self.extension() {
e == ext
} else {
false
}
}
}
fn actual_test(path: &str) {
let path = path::Path::new(path);
let expected = load_file(&path.with_extension("yaml"));
let opt = ParsingOptions {
allow_dtd: true,
..roxmltree::ParsingOptions::default()
};
let input_xml = load_file(path);
let doc = match Document::parse_with_options(&input_xml, opt) {
Ok(v) => v,
Err(e) => {
assert_eq!(TStr(&format!("error: \"{}\"", e)), TStr(expected.trim()));
return;
}
};
assert_eq!(TStr(&to_yaml(&doc)), TStr(&expected));
}
fn load_file(path: &path::Path) -> String {
let mut file = fs::File::open(path).unwrap();
let mut text = String::new();
file.read_to_string(&mut text).unwrap();
text
}
fn to_yaml(doc: &Document) -> String {
let mut s = String::new();
_to_yaml(doc, &mut s).unwrap();
s
}
fn _to_yaml(doc: &Document, s: &mut String) -> Result<(), fmt::Error> {
if !doc.root().has_children() {
return write!(s, "Document:");
}
macro_rules! writeln_indented {
($depth:expr, $f:expr, $fmt:expr) => {
for _ in 0..$depth { write!($f, " ")?; }
writeln!($f, $fmt)?;
};
($depth:expr, $f:expr, $fmt:expr, $($arg:tt)*) => {
for _ in 0..$depth { write!($f, " ")?; }
writeln!($f, $fmt, $($arg)*)?;
};
}
fn print_children(parent: Node, depth: usize, s: &mut String) -> Result<(), fmt::Error> {
for child in parent.children() {
match child.node_type() {
NodeType::Element => {
writeln_indented!(depth, s, "- Element:");
match child.tag_name().namespace() {
Some(ns) => {
if ns.is_empty() {
writeln_indented!(
depth + 2,
s,
"tag_name: {}",
child.tag_name().name()
);
} else {
writeln_indented!(
depth + 2,
s,
"tag_name: {}@{}",
child.tag_name().name(),
ns
);
}
}
None => {
writeln_indented!(
depth + 2,
s,
"tag_name: {}",
child.tag_name().name()
);
}
}
let attributes = child.attributes();
if attributes.len() != 0 {
let mut attrs = Vec::new();
for attr in attributes {
match attr.namespace() {
Some(ns) => {
attrs.push((format!("{}@{}", attr.name(), ns), attr.value()));
}
None => {
attrs.push((attr.name().to_string(), attr.value()));
}
}
}
attrs.sort_by(|a, b| a.0.cmp(&b.0));
writeln_indented!(depth + 2, s, "attributes:");
for (name, value) in attrs {
writeln_indented!(depth + 3, s, "{}: {:?}", name, value);
}
}
let namespaces = child.namespaces();
if namespaces.len() != 0 {
let mut ns_list = Vec::new();
for ns in namespaces {
let name = ns.name().unwrap_or("None");
let uri = if ns.uri().is_empty() {
"\"\""
} else {
ns.uri()
};
ns_list.push((name, uri));
}
ns_list.sort_by(|a, b| a.0.cmp(b.0));
writeln_indented!(depth + 2, s, "namespaces:");
for (name, uri) in ns_list {
writeln_indented!(depth + 3, s, "{}: {}", name, uri);
}
}
if child.has_children() {
writeln_indented!(depth + 2, s, "children:");
print_children(child, depth + 3, s)?;
}
}
NodeType::Text => {
writeln_indented!(depth, s, "- Text: {:?}", child.text().unwrap());
}
NodeType::Comment => {
writeln_indented!(depth, s, "- Comment: {:?}", child.text().unwrap());
}
NodeType::PI => {
if child.parent().unwrap().is_root() {
continue;
}
writeln_indented!(depth, s, "- PI:");
let pi = child.pi().unwrap();
writeln_indented!(depth + 2, s, "target: {:?}", pi.target);
if let Some(value) = pi.value {
writeln_indented!(depth + 2, s, "value: {:?}", value);
}
}
NodeType::Root => {}
}
}
Ok(())
}
writeln!(s, "Document:")?;
print_children(doc.root(), 1, s)?;
Ok(())
}
macro_rules! test {
($name:ident) => {
#[test]
fn $name() {
actual_test(&format!("tests/files/{}.xml", stringify!($name)))
}
};
}
test!(attrs_001);
test!(attrs_002);
test!(attrs_003);
test!(attrs_004);
test!(attrs_005);
test!(attrs_006);
test!(attrs_err_001);
test!(attrs_err_002);
test!(cdata_001);
test!(cdata_002);
test!(cdata_003);
test!(cdata_004);
test!(cdata_005);
test!(cdata_006);
test!(cdata_007);
test!(comments_001);
test!(elems_err_001);
test!(elems_err_002);
test!(entity_001);
test!(entity_002);
test!(entity_003);
test!(entity_004);
test!(entity_005);
test!(entity_006);
test!(entity_007);
test!(entity_008);
test!(entity_009);
test!(entity_010);
test!(entity_011);
test!(entity_012);
test!(entity_013);
test!(entity_014);
test!(entity_err_001);
test!(entity_err_002);
test!(entity_err_003);
test!(entity_err_004);
test!(entity_err_005);
test!(entity_err_006);
test!(entity_err_007);
test!(entity_err_008);
test!(entity_err_009);
test!(ns_001);
test!(ns_002);
test!(ns_003);
test!(ns_004);
test!(ns_005);
test!(ns_006);
test!(ns_007);
test!(ns_008);
test!(ns_009);
test!(ns_010);
test!(ns_011);
test!(ns_012);
test!(ns_013);
test!(ns_014);
test!(ns_015);
test!(ns_016);
test!(ns_017);
test!(ns_err_001);
test!(ns_err_002);
test!(ns_err_003);
test!(ns_err_004);
test!(ns_err_005);
test!(ns_err_006);
test!(ns_err_007);
test!(ns_err_008);
test!(ns_err_009);
test!(ns_err_010);
test!(ns_err_011);
test!(ns_err_012);
test!(ns_err_013);
test!(text_001);
test!(text_002);
test!(text_003);
test!(text_004);
test!(text_005);
test!(text_006);
test!(text_007);
test!(text_008);
test!(text_009);
test!(text_010);
test!(text_011);
test!(text_012);
test!(tree_001);
test!(tree_002);
// test!(tree_003); // unsupported
test!(tree_err_001);
test!(tree_err_002);
test!(tree_err_003);

205
vendor/roxmltree/tests/dom-api.rs vendored Normal file
View File

@@ -0,0 +1,205 @@
use roxmltree::*;
// Document.getElementsByTagName()
#[test]
fn get_elements_by_tag_name() {
let data = "\
<!-- comment -->
<svg>
<rect/>
<text>Text</text>
<g>
<!-- comment -->
<rect/>
</g>
</svg>
";
let doc = Document::parse(data).unwrap();
let nodes: Vec<Node> = doc
.descendants()
.filter(|n| n.has_tag_name("rect"))
.collect();
assert_eq!(nodes.len(), 2);
}
// Document.getElementsByTagNameNS()
#[test]
fn get_elements_by_tag_name_ns() {
let data = "\
<!-- comment -->
<svg xmlns:q='http://www.w3.org/'>
<rect/>
<text>Text</text>
<g>
<!-- comment -->
<q:rect/>
</g>
</svg>
";
let doc = Document::parse(data).unwrap();
let nodes: Vec<Node> = doc
.descendants()
.filter(|n| n.has_tag_name(("http://www.w3.org/", "rect")))
.collect();
assert_eq!(nodes.len(), 1);
}
// ParentNode.childElementCount
#[test]
fn child_element_count() {
let data = "\
<svg>
<rect/>
<!-- comment -->
<rect/>
<!-- comment -->
<rect/>
</svg>
";
let doc = Document::parse(data).unwrap();
let svg_elem = doc.root_element();
let count = svg_elem.children().filter(|n| n.is_element()).count();
assert_eq!(count, 3);
}
// ParentNode.children
#[test]
fn children() {
let data = "\
<svg>
<rect/>
<!-- comment -->
<rect/>
<!-- comment -->
<rect/>
</svg>
";
let doc = Document::parse(data).unwrap();
let svg_elem = doc.root_element();
let count = svg_elem.children().filter(|n| n.is_element()).count();
assert_eq!(count, 3);
}
// ParentNode.firstElementChild
#[test]
fn first_element_child() {
let data = "\
<svg>
<!-- comment -->
<rect/>
</svg>
";
let doc = Document::parse(data).unwrap();
let svg_elem = doc.root_element();
let elem = svg_elem.first_element_child().unwrap();
assert!(elem.has_tag_name("rect"));
// or
let elem = svg_elem.children().find(|n| n.is_element()).unwrap();
assert!(elem.has_tag_name("rect"));
}
// ParentNode.lastElementChild
#[test]
fn last_element_child() {
let data = "\
<svg>
<!-- comment -->
<rect/>
<!-- comment -->
</svg>
";
let doc = Document::parse(data).unwrap();
let svg_elem = doc.root_element();
let elem = svg_elem.last_element_child().unwrap();
assert!(elem.has_tag_name("rect"));
// or
let elem = svg_elem
.children()
.filter(|n| n.is_element())
.last()
.unwrap();
assert!(elem.has_tag_name("rect"));
}
// Document.getElementById
#[test]
fn get_element_by_id() {
let data = "\
<svg id='svg1'>
<circle id='circle1'/>
<g>
<rect id='rect1'/>
</g>
</svg>
";
let doc = Document::parse(data).unwrap();
let elem = doc
.descendants()
.find(|n| n.attribute("id") == Some("rect1"))
.unwrap();
assert!(elem.has_tag_name("rect"));
}
// Node.ownerDocument
#[test]
fn owner_document() {
let doc = Document::parse("<svg/>").unwrap();
let _elem = doc.root_element();
}
// Node.parentElement
#[test]
fn parent_element() {
let data = "\
<svg>
<!-- comment -->
<rect/>
</svg>
";
let doc = Document::parse(data).unwrap();
let rect = doc.descendants().find(|n| n.has_tag_name("rect")).unwrap();
assert!(rect.parent_element().unwrap().has_tag_name("svg"));
// or
assert!(rect
.ancestors()
.skip(1)
.find(|n| n.is_element())
.unwrap()
.has_tag_name("svg"));
}
// Node.contains
#[test]
fn contains() {
let data = "\
<svg>
<rect/>
</svg>
";
let doc = Document::parse(data).unwrap();
let svg = doc.root_element();
let rect = svg.first_child().unwrap();
assert!(svg.descendants().any(|n| n == rect));
}

91
vendor/roxmltree/tests/files/README.md vendored Normal file
View File

@@ -0,0 +1,91 @@
### Tests
- attrs_001 - simple attribute
- attrs_002 - attribute value with new lines
- attrs_003 - attribute value with escaped text
- attrs_004 - attribute value with escaped text
- attrs_005 - attribute value with \r\n
- attrs_006 - escaped `<`
- attrs_err_001 - duplicated attributes
- attrs_err_002 - duplicated attributes via namespaces
- cdata_001 - simple case
- cdata_002 - simple case
- cdata_003 - empty
- cdata_004 - simple case
- cdata_005 - mixed text and cdata
- cdata_006 - simple case
- cdata_007 - with \r
- comments_001 - comment before and after the root element
- elems_err_001 - invalid tree structure
- elems_err_002 - invalid tree structure with namespace
- entity_001 - entity reference to an element
- entity_002 - entity reference to an attribute value
- entity_003 - many entity references to an attribute value
- entity_004 - entity reference to a text
- entity_005 - unused entity reference
- entity_006 - entity reference to an escaped text
- entity_007 - indirect entity reference to an attribute value
- entity_008 - entity reference to an element
- entity_009 - entity reference to a mixed content
- entity_010 - entity reference to an element with an entity reference
- entity_011 - character and entity references in attributes
- entity_012 - mixed entity references in text
- entity_013 - many entity references in text
- entity_014 - many entity references in attribute
- entity_err_001 - unknown entity reference
- entity_err_002 - recursive entity references
- entity_err_003 - reference to a close tag
- entity_err_004 - reference to a close tag
- entity_err_005 - billion laughs
- entity_err_006 - billion laughs
- entity_err_007 - malformed entity inside an attribute
- entity_err_008 - malformed entity inside a character data/text
- entity_err_009 - escaped `<` inside an attribute inside an entity is an error
- ns_001 - attributes with different namespaces
- ns_002 - attribute is not affected by the default namespace
- ns_003 - attributes with different namespaces
- ns_004 - `href` with a custom prefix
- ns_005 - `xml` namespace resolving
- ns_006 - `xml` namespace overriding
- ns_007 - many namespaces
- ns_008 - namespace propagation
- ns_009 - namespace overwriting
- ns_010 - indirect namespace propagation
- ns_011 - empty URI
- ns_012 - namespace propagation
- ns_013 - namespace from entity
- ns_014 - no namespaces
- ns_015 - duplicated namespaces with different prefixes and a child element without prefix
- ns_016 - an empty element with namespace on parent
- ns_017 - duplicated namespaces with different prefixes and a child element with prefix
- ns_err_001 - invalid `xml` URI
- ns_err_002 - reserved URI
- ns_err_003 - reserved URI
- ns_err_004 - duplicated namespaces
- ns_err_005 - escaped namespace
- ns_err_006 - escaped namespace
- ns_err_007 - reserved URI
- ns_err_008 - reserved URI
- ns_err_009 - `xmlns` cannot be used as an element prefix
- ns_err_010 - an element with an unknown namespace
- ns_err_011 - an attribute with an unknown namespace
- ns_err_012 - closing tag with missing namespace prefix
- ns_err_013 - closing tag with missing namespace prefix and default namespace
- text_001 - single space text
- text_002 - single escaped space text
- text_003 - escaped text
- text_004 - '>' text
- text_005 - '\n\r\r\n' text
- text_006 - '\r\r\r' text
- text_007 - '\r\n\r\n' text
- text_008 - only whitespaces
- text_009 - escaped text
- text_010 - text around elements
- text_011 - mixed character references in text
- text_012 - non-ASCII text
- tree_001 - all node types
- tree_002 - BOM
- tree_003 - Windows-1251 encoding
- tree_err_001 - no elements
- tree_err_002 - root element not closed
- tree_err_003 - child element not closed

View File

@@ -0,0 +1 @@
<p a='b'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
attributes:
a: "b"

View File

@@ -0,0 +1,3 @@
<p a='
xyz'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
attributes:
a: " xyz"

View File

@@ -0,0 +1 @@
<p a='A&#x20;B'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
attributes:
a: "A B"

View File

@@ -0,0 +1 @@
<p a='&#xd;&#xd;A&#xa;&#xa;B&#xd;&#xa;'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
attributes:
a: "\r\rA\n\nB\r\n"

View File

@@ -0,0 +1,3 @@
<e a='
b
'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: e
attributes:
a: " b "

View File

@@ -0,0 +1 @@
<e a='&lt;'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: e
attributes:
a: "<"

View File

@@ -0,0 +1 @@
<e a='b1' a='b2'/>

View File

@@ -0,0 +1 @@
error: "attribute 'a' at 1:11 is already defined"

View File

@@ -0,0 +1 @@
<e xmlns:n1='http://www.w3.org' xmlns:n2='http://www.w3.org' n1:a='b1' n2:a='b2'/>

View File

@@ -0,0 +1 @@
error: "attribute 'a' at 1:72 is already defined"

View File

@@ -0,0 +1,3 @@
<doc>
<![CDATA[<greeting>Hello, world!</greeting>]]>
</doc>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: doc
children:
- Text: "\n<greeting>Hello, world!</greeting>\n"

View File

@@ -0,0 +1,3 @@
<e><![CDATA[
<![CDATA[abc]]]>]&gt;<![CDATA[
]]></e>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: e
children:
- Text: "\n <![CDATA[abc]]>\n "

View File

@@ -0,0 +1,3 @@
<p>
<![CDATA[]]>
</p>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
children:
- Text: "\n \n"

View File

@@ -0,0 +1,7 @@
<p>
some
<p>
<![CDATA[long]]>
</p>
text
</p>

View File

@@ -0,0 +1,10 @@
Document:
- Element:
tag_name: p
children:
- Text: "\n some\n "
- Element:
tag_name: p
children:
- Text: "\n long\n "
- Text: "\n text\n"

View File

@@ -0,0 +1 @@
<p>T<![CDATA[e]]>x<![CDATA[t]]></p>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
children:
- Text: "Text"

View File

@@ -0,0 +1,5 @@
<svg>
<style><![CDATA[
text
]]></style>
</svg>

After

Width:  |  Height:  |  Size: 63 B

View File

@@ -0,0 +1,10 @@
Document:
- Element:
tag_name: svg
children:
- Text: "\n "
- Element:
tag_name: style
children:
- Text: "\n text\n "
- Text: "\n"

View File

@@ -0,0 +1,4 @@
<svg>
<style><![CDATA[some
long
text

After

Width:  |  Height:  |  Size: 61 B

View File

@@ -0,0 +1,10 @@
Document:
- Element:
tag_name: svg
children:
- Text: "\n "
- Element:
tag_name: style
children:
- Text: "some\nlong\ntext\n"
- Text: "\n"

View File

@@ -0,0 +1,3 @@
<!-- comment -->
<root/>
<!-- comment -->

View File

@@ -0,0 +1,5 @@
Document:
- Comment: " comment "
- Element:
tag_name: root
- Comment: " comment "

View File

@@ -0,0 +1,3 @@
<root>
<item>
</root>

View File

@@ -0,0 +1 @@
error: "expected 'item' tag, not 'root' at 3:1"

View File

@@ -0,0 +1,3 @@
<t:root xmlns:t='http://www.w3.org'>
<t:item>
</t:root>

View File

@@ -0,0 +1 @@
error: "expected 't:item' tag, not 't:root' at 3:1"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY p '<p/>'>
]>
<root>&p;</root>

View File

@@ -0,0 +1,6 @@
Document:
- Element:
tag_name: root
children:
- Element:
tag_name: p

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY v 'b'>
]>
<p a='&v;'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
attributes:
a: "b"

View File

@@ -0,0 +1,6 @@
<!DOCTYPE test [
<!ENTITY d '&#xD;'>
<!ENTITY a '&#xA;'>
<!ENTITY da '&#xD;&#xA;'>
]>
<p a='&d;&d;A&a;&#x20;&a;B&da;'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
attributes:
a: " A B "

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY b 'text'>
]>
<p>&b;</p>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
children:
- Text: "text"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY b 'text'>
]>
<e/>

View File

@@ -0,0 +1,3 @@
Document:
- Element:
tag_name: e

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY b 'Some&#x20;text'>
]>
<p>&b;</p>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: p
children:
- Text: "Some text"

View File

@@ -0,0 +1,5 @@
<!DOCTYPE test [
<!ENTITY a '&b;'>
<!ENTITY b 'text'>
]>
<e a='&a;'/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: e
attributes:
a: "text"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY p ' <p/> '>
]>
<root>&p;</root>

View File

@@ -0,0 +1,8 @@
Document:
- Element:
tag_name: root
children:
- Text: " "
- Element:
tag_name: p
- Text: " "

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY p 'text<p/>text'>
]>
<root>&p;</root>

View File

@@ -0,0 +1,8 @@
Document:
- Element:
tag_name: root
children:
- Text: "text"
- Element:
tag_name: p
- Text: "text"

View File

@@ -0,0 +1,5 @@
<!DOCTYPE test [
<!ENTITY q 'b'>
<!ENTITY p '<p a="&q;"/>'>
]>
<root>&p;</root>

View File

@@ -0,0 +1,8 @@
Document:
- Element:
tag_name: root
children:
- Element:
tag_name: p
attributes:
a: "b"

View File

@@ -0,0 +1,9 @@
<!DOCTYPE test [
<!ENTITY d '&#xD;'>
<!ENTITY a '&#xA;'>
<!ENTITY da '&#xD;&#xA;'>
]>
<root>
<p a='&d;&d;A&a;&a;B&da;&da;'/>
<p a='&#xD;&#xD;A&#xA;&#xA;B&#xD;&#xA;&#xD;&#xA;'/>
</root>

View File

@@ -0,0 +1,15 @@
Document:
- Element:
tag_name: root
children:
- Text: "\n "
- Element:
tag_name: p
attributes:
a: " A B "
- Text: "\n "
- Element:
tag_name: p
attributes:
a: "\r\rA\n\nB\r\n\r\n"
- Text: "\n"

View File

@@ -0,0 +1,43 @@
<!DOCTYPE test [
<!ENTITY d '&#xD;'>
<!ENTITY a '&#xA;'>
<!ENTITY da '&#xD;&#xA;'>
]>
<root>
<p id="1">&a;</p>
<p id="2">&a;&a;</p>
<p id="3">&a;&a;&a;</p>
<p id="4">&d;</p>
<p id="5">&d;&d;</p>
<p id="6">&d;&d;&d;</p>
<p id="7">&a;&d;</p>
<p id="8">&d;&a;</p>
<p id="9">&a;&d;&a;</p>
<p id="10">&d;&a;&d;</p>
<p id="11">&a;q&a;</p>
<p id="12">&d;q&d;</p>
<p id="13">&a;q&d;</p>
<p id="14">&d;q&a;</p>
<p id="15">&a;&da;</p>
<p id="16">&da;&a;</p>
<p id="17">&d;&da;</p>
<p id="18">&da;&d;</p>
<p id="19">&da;&da;</p>
<p id="20">&a;&a;q</p>
<p id="21">q&a;&a;</p>
<p id="22">q&a;&a;q</p>
<p id="23">&d;&d;q</p>
<p id="24">q&d;&d;</p>
<p id="25">q&d;&d;q</p>
<p id="26">&da;&da;q</p>
<p id="27">q&da;&da;</p>
<p id="28">q&da;&da;q</p>
</root>

View File

@@ -0,0 +1,201 @@
Document:
- Element:
tag_name: root
children:
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "1"
children:
- Text: "\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "2"
children:
- Text: "\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "3"
children:
- Text: "\n\n\n"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "4"
children:
- Text: "\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "5"
children:
- Text: "\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "6"
children:
- Text: "\n\n\n"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "7"
children:
- Text: "\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "8"
children:
- Text: "\n\n"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "9"
children:
- Text: "\n\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "10"
children:
- Text: "\n\n\n"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "11"
children:
- Text: "\nq\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "12"
children:
- Text: "\nq\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "13"
children:
- Text: "\nq\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "14"
children:
- Text: "\nq\n"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "15"
children:
- Text: "\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "16"
children:
- Text: "\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "17"
children:
- Text: "\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "18"
children:
- Text: "\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "19"
children:
- Text: "\n\n"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "20"
children:
- Text: "\n\nq"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "21"
children:
- Text: "q\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "22"
children:
- Text: "q\n\nq"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "23"
children:
- Text: "\n\nq"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "24"
children:
- Text: "q\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "25"
children:
- Text: "q\n\nq"
- Text: "\n\n "
- Element:
tag_name: p
attributes:
id: "26"
children:
- Text: "\n\nq"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "27"
children:
- Text: "q\n\n"
- Text: "\n "
- Element:
tag_name: p
attributes:
id: "28"
children:
- Text: "q\n\nq"
- Text: "\n"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY q 'q'>
]>
<root>&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;</root>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: root
children:
- Text: "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY q 'q'>
]>
<root a="&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;&q;"/>

View File

@@ -0,0 +1,5 @@
Document:
- Element:
tag_name: root
attributes:
a: "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"

View File

@@ -0,0 +1 @@
<e a='&d;'/>

View File

@@ -0,0 +1 @@
error: "unknown entity reference 'd' at 1:7"

View File

@@ -0,0 +1,5 @@
<!DOCTYPE test [
<!ENTITY a '&b;'>
<!ENTITY b '&a;'>
]>
<e a='&a;'/>

View File

@@ -0,0 +1 @@
error: "a possible entity reference loop is detected at 3:20"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY p '</p>'>
]>
<root>&p;</root>

View File

@@ -0,0 +1 @@
error: "unexpected close tag at 2:17"

View File

@@ -0,0 +1,4 @@
<!DOCTYPE test [
<!ENTITY p '</p>'>
]>
<root><p>&p;</root>

View File

@@ -0,0 +1 @@
error: "unexpected close tag at 2:17"

View File

@@ -0,0 +1,13 @@
<!DOCTYPE lolz [
<!ENTITY lol "lol">
<!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
<!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
<!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">
<!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">
<!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">
<!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">
<!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">
]>
<lolz>&lol9;</lolz>

View File

@@ -0,0 +1 @@
error: "a possible entity reference loop is detected at 3:40"

View File

@@ -0,0 +1,13 @@
<!DOCTYPE lolz [
<!ENTITY lol "lol">
<!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
<!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
<!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">
<!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">
<!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">
<!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">
<!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">
]>
<lolz a="&lol9;"/>

View File

@@ -0,0 +1 @@
error: "a possible entity reference loop is detected at 3:40"

View File

@@ -0,0 +1 @@
<p a="&amp"/>

View File

@@ -0,0 +1 @@
error: "malformed entity reference at 1:7"

View File

@@ -0,0 +1 @@
<p>&amp</p>

Some files were not shown because too many files have changed in this diff Show More