From 35dfdca2b183d8137a6206fbe65c5dc012f221aa Mon Sep 17 00:00:00 2001 From: Kornel Date: Sun, 19 Jun 2022 12:06:22 +0100 Subject: [PATCH] Deprecate unnecessary unescaping of tags Fixes #341 --- src/events/mod.rs | 33 ++++++++++++++++++++++++++------- tests/test.rs | 1 + 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/events/mod.rs b/src/events/mod.rs index 227d55da..f09c1a89 100644 --- a/src/events/mod.rs +++ b/src/events/mod.rs @@ -179,7 +179,10 @@ impl<'a> BytesStart<'a> { /// "`<`". /// /// See also [`unescaped_with_custom_entities()`](#method.unescaped_with_custom_entities) - #[inline] + #[cold] + #[deprecated(note = "Tag names are never escaped. Attributes must be unescaped individually")] + #[allow(deprecated)] + #[doc(hidden)] pub fn unescaped(&self) -> Result> { self.make_unescaped(None) } @@ -195,7 +198,10 @@ impl<'a> BytesStart<'a> { /// The keys and values of `custom_entities`, if any, must be valid UTF-8. /// /// See also [`unescaped()`](#method.unescaped) - #[inline] + #[cold] + #[deprecated(note = "Tag names are never escaped. Attributes must be unescaped individually")] + #[allow(deprecated)] + #[doc(hidden)] pub fn unescaped_with_custom_entities<'s>( &'s self, custom_entities: &HashMap, Vec>, @@ -203,7 +209,8 @@ impl<'a> BytesStart<'a> { self.make_unescaped(Some(custom_entities)) } - #[inline] + #[cold] + #[deprecated(note = "Tag names are never escaped. Attributes must be unescaped individually")] fn make_unescaped<'s>( &'s self, custom_entities: Option<&HashMap, Vec>>, @@ -221,7 +228,10 @@ impl<'a> BytesStart<'a> { /// /// [`unescaped()`]: #method.unescaped /// [`Reader::decode()`]: ../reader/struct.Reader.html#method.decode - #[inline] + #[cold] + #[deprecated(note = "Tag names are never escaped. Attributes must be unescaped individually")] + #[allow(deprecated)] + #[doc(hidden)] pub fn unescape_and_decode(&self, reader: &Reader) -> Result { self.do_unescape_and_decode_with_custom_entities(reader, None) } @@ -240,7 +250,10 @@ impl<'a> BytesStart<'a> { /// # Pre-condition /// /// The keys and values of `custom_entities`, if any, must be valid UTF-8. - #[inline] + #[cold] + #[deprecated(note = "Tag names are never escaped. Attributes must be unescaped individually")] + #[allow(deprecated)] + #[doc(hidden)] pub fn unescape_and_decode_with_custom_entities( &self, reader: &Reader, @@ -250,7 +263,10 @@ impl<'a> BytesStart<'a> { } #[cfg(feature = "encoding")] - #[inline] + #[cold] + #[deprecated(note = "Tag names are never escaped. Attributes must be unescaped individually")] + #[allow(deprecated)] + #[doc(hidden)] fn do_unescape_and_decode_with_custom_entities( &self, reader: &Reader, @@ -263,7 +279,10 @@ impl<'a> BytesStart<'a> { } #[cfg(not(feature = "encoding"))] - #[inline] + #[cold] + #[deprecated(note = "Tag names are never escaped. Attributes must be unescaped individually")] + #[allow(deprecated)] + #[doc(hidden)] fn do_unescape_and_decode_with_custom_entities( &self, reader: &Reader, diff --git a/tests/test.rs b/tests/test.rs index 37426391..8d56b09c 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -156,6 +156,7 @@ fn fuzz_101() { loop { match reader.read_event(&mut buf) { Ok(Start(ref e)) | Ok(Empty(ref e)) => { + #[allow(deprecated)] if e.unescaped().is_err() { break; }