-
Notifications
You must be signed in to change notification settings - Fork 231
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
Rework handling general entity references (&entity;
)
#766
base: master
Are you sure you want to change the base?
Conversation
da2a802
to
6d9a6ab
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #766 +/- ##
==========================================
- Coverage 61.81% 60.13% -1.69%
==========================================
Files 41 41
Lines 16798 16492 -306
==========================================
- Hits 10384 9917 -467
- Misses 6414 6575 +161
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I finished work on the base part of the entities support. In this PR new |
I won't have a chance to fully review this for a couple of days. Quick question though, am I correct in thinking that this PR will mean that any time a text block contains one or more entity references, instead of the developer receiving one |
Yes, you are correct. But that does not mean that he/she will needed to construct the complete text themselves. In the next PR I plan to rename Because renames affects very many places, I want to do that in a separate PR to reduce noise in PR with new Borrow-only reader-only events will be useful also in that sense that I plan to add Because new |
src/reader/mod.rs
Outdated
Ok((_, false)) => { | ||
// We want to report error at `&`, but offset was increased, | ||
// so return it back (-1 for `&`) | ||
$self.state.last_error_offset = start - 1; | ||
Err(Error::Syntax(SyntaxError::UnclosedReference)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a code in ruffle in ruffle-rs/ruffle#10471 from @Aaron1011 that will be break (custom_unescape
function), because currently dangling &
will always return SyntaxError::UnclosedReference
. I think I should add a new configuration option for this here
b307997
to
51676d2
Compare
@dralley, what do you think about this? |
…onstruction in a text failures (16): serde-de (9): borrow::escaped::element borrow::escaped::top_level resolve::resolve_custom_entity trivial::text::byte_buf trivial::text::bytes trivial::text::string::field trivial::text::string::naked trivial::text::string::text xml_schema_lists::element::text::string serde-migrated (1): test_parse_string serde-se (5): with_root::char_amp with_root::char_gt with_root::char_lt with_root::str_escaped with_root::tuple --doc (1): src\de\resolver.rs - de::resolver::EntityResolver (line 13)
…xpanded entities
Text events produces by the Reader can not contain escaped data anymore, all such data is represented by the Event::GeneralRef
Fixed (18): serde-de (9): borrow::escaped::element borrow::escaped::top_level resolve::resolve_custom_entity trivial::text::byte_buf trivial::text::bytes trivial::text::string::field trivial::text::string::naked trivial::text::string::text xml_schema_lists::element::text::string serde-migrated (1): test_parse_string serde-se (5): with_root::char_amp with_root::char_gt with_root::char_lt with_root::str_escaped with_root::tuple --doc (3): src\de\resolver.rs - de::resolver::EntityResolver (line 13)
@@ -24,6 +24,9 @@ XML specification. See the updated `custom_entities` example! | |||
|
|||
- [#766]: Allow to parse resolved entities as XML fragments and stream events from them. | |||
- [#766]: Added new event `Event::GeneralRef` with content of [general entity]. | |||
- [#766]: Added new configuration option `allow_dangling_amp` which allows to have | |||
a `&` not followed by `;` in the textual data which is required for some applications | |||
for compatibility reasons. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which applications?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant case from #719 here
This is a big change in handling general entity references and character references. Open PR early to get feedback.
With this changes we can correctly parse document
as equivalent normalized document
<root/>
The updated
custom_entities
example shows how it would be possible to implement requirement from the specification about parsed general entities. Serde deserializer did not updated yet, because this is not trivial part and probably that will be done in another PR.Of course, such change probably makes the performance worse, I didn't measure impact yet.
Closes #667