Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when parsing malformed XML: "Proper bang start guaranteed by read_bang_elem" #344

Closed
5225225 opened this issue Nov 29, 2021 · 0 comments

Comments

@5225225
Copy link
Contributor

5225225 commented Nov 29, 2021

Reproduction:

fn main() {
    let doc = "<!D>";
    let mut reader = quick_xml::Reader::from_str(doc);
    let mut buf = Vec::new();
    reader.read_event(&mut buf);
    reader.read_event(&mut buf);
}

Tested on 521d72a

@5225225 5225225 changed the title Panic when parsing malformed XML: "Proper bang start guarenteed by bang_read_elem" Panic when parsing malformed XML: "Proper bang start guaranteed by read_bang_elem" Nov 29, 2021
Mingun referenced this issue in Mingun/fast-xml Mar 8, 2022
…ion and fix part of #344

As a result the same optimization is applied for borrowed parsed in DOCTYPE
parsing as in non-borrowing one

This fixes the following tests (which is the reason of #344):
- reader::test::buffered::read_bang_element::comment::not_closed3
- reader::test::buffered::read_bang_element::comment::with_content
Mingun referenced this issue in Mingun/fast-xml Mar 8, 2022
Mingun referenced this issue in Mingun/fast-xml Mar 8, 2022
Mingun added a commit to Mingun/fast-xml that referenced this issue May 2, 2022
…ion and fix part of tafia/quick-xml#344

As a result the same optimization is applied for borrowed parsed in DOCTYPE
parsing as in non-borrowing one

This fixes the following tests (which is the reason of #344):
- reader::test::buffered::read_bang_element::comment::not_closed3
- reader::test::buffered::read_bang_element::comment::with_content
Mingun added a commit to Mingun/fast-xml that referenced this issue May 2, 2022
failures (8):
    reader::test::borrowed::issue_344::cdata
    reader::test::borrowed::issue_344::comment
    reader::test::borrowed::issue_344::doctype_lowercase
    reader::test::borrowed::issue_344::doctype_uppercase
    reader::test::buffered::issue_344::cdata
    reader::test::buffered::issue_344::comment
    reader::test::buffered::issue_344::doctype_lowercase
    reader::test::buffered::issue_344::doctype_uppercase
@Mingun Mingun closed this as completed in 914bca9 May 21, 2022
crapStone added a commit to Calciumdibromid/CaBr2 that referenced this issue May 30, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [quick-xml](https://github.com/tafia/quick-xml) | dependencies | patch | `0.23.0-alpha3` -> `0.23.0` |
| [quick-xml](https://github.com/tafia/quick-xml) | dependencies | minor | `0.22.0` -> `0.23.0` |

---

### Release Notes

<details>
<summary>tafia/quick-xml</summary>

### [`v0.23.0`](https://github.com/tafia/quick-xml/blob/HEAD/Changelog.md#&#8203;0230----2022-05-08)

-   feat: add support for `i128` / `u128` in attributes or text/CDATA content
-   test: add tests for malformed inputs for serde deserializer
-   fix: allow to deserialize `unit`s from any data in attribute values and text nodes
-   refactor: unify errors when EOF encountered during serde deserialization
-   test: ensure that after deserializing all XML was consumed
-   feat: add `Deserializer::from_str`, `Deserializer::from_slice` and `Deserializer::from_reader`
-   refactor: deprecate `from_bytes` and `Deserializer::from_borrowing_reader` because
    they are fully equivalent to `from_slice` and `Deserializer::new`
-   refactor: reduce number of unnecessary copies when deserialize numbers/booleans/identifiers
    from the attribute and element names and attribute values
-   fix: allow to deserialize `unit`s from text and CDATA content.
    `DeError::InvalidUnit` variant is removed, because after fix it is no longer used
-   fix: `ElementWriter`, introduced in [#&#8203;274](tafia/quick-xml#274)
    (0.23.0-alpha2) now available to end users
-   fix: allow lowercase `<!doctype >` definition (used in HTML 5) when parse document from `&[u8]`
-   test: add tests for consistence behavior of buffered and borrowed readers
-   fix: produce consistent error positions in buffered and borrowed readers
-   feat: `Error::UnexpectedBang` now provide the byte found
-   refactor: unify code for buffered and borrowed readers
-   fix: fix internal panic message when parse malformed XML
    ([#&#8203;344](tafia/quick-xml#344))
-   test: add tests for trivial documents (empty / only comment / `<root>...</root>` -- one tag with content)
-   fix: CDATA was not handled in many cases where it should
-   fix: do not unescape CDATA content because it never escaped by design.
    CDATA event data now represented by its own `BytesCData` type
    ([quick-xml#&#8203;311](tafia/quick-xml#311))
-   feat: add `Reader::get_ref()` and `Reader::get_mut()`, rename
    `Reader::into_underlying_reader()` to `Reader::into_inner()`
-   refactor: now `Attributes::next()` returns a new type `AttrError` when attribute parsing failed
    ([#&#8203;4](Mingun/fast-xml#4))
-   test: properly test all paths of attributes parsing ([#&#8203;4](Mingun/fast-xml#4))
-   feat: attribute iterator now implements `FusedIterator` ([#&#8203;4](Mingun/fast-xml#4))
-   fix: fixed many errors in attribute parsing using iterator, returned from `attributes()`
    or `html_attributes()` ([#&#8203;4](Mingun/fast-xml#4))

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Co-authored-by: crapStone <crapstone01@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1377
Reviewed-by: crapStone <crapstone@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant