Skip to content

Commit 35dfdca

Browse files
committed
Deprecate unnecessary unescaping of tags
Fixes tafia#341
1 parent e701c4d commit 35dfdca

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

src/events/mod.rs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ impl<'a> BytesStart<'a> {
179179
/// "`<`".
180180
///
181181
/// See also [`unescaped_with_custom_entities()`](#method.unescaped_with_custom_entities)
182-
#[inline]
182+
#[cold]
183+
#[deprecated(note = "Tag names are never escaped. Attributes must be unescaped individually")]
184+
#[allow(deprecated)]
185+
#[doc(hidden)]
183186
pub fn unescaped(&self) -> Result<Cow<[u8]>> {
184187
self.make_unescaped(None)
185188
}
@@ -195,15 +198,19 @@ impl<'a> BytesStart<'a> {
195198
/// The keys and values of `custom_entities`, if any, must be valid UTF-8.
196199
///
197200
/// See also [`unescaped()`](#method.unescaped)
198-
#[inline]
201+
#[cold]
202+
#[deprecated(note = "Tag names are never escaped. Attributes must be unescaped individually")]
203+
#[allow(deprecated)]
204+
#[doc(hidden)]
199205
pub fn unescaped_with_custom_entities<'s>(
200206
&'s self,
201207
custom_entities: &HashMap<Vec<u8>, Vec<u8>>,
202208
) -> Result<Cow<'s, [u8]>> {
203209
self.make_unescaped(Some(custom_entities))
204210
}
205211

206-
#[inline]
212+
#[cold]
213+
#[deprecated(note = "Tag names are never escaped. Attributes must be unescaped individually")]
207214
fn make_unescaped<'s>(
208215
&'s self,
209216
custom_entities: Option<&HashMap<Vec<u8>, Vec<u8>>>,
@@ -221,7 +228,10 @@ impl<'a> BytesStart<'a> {
221228
///
222229
/// [`unescaped()`]: #method.unescaped
223230
/// [`Reader::decode()`]: ../reader/struct.Reader.html#method.decode
224-
#[inline]
231+
#[cold]
232+
#[deprecated(note = "Tag names are never escaped. Attributes must be unescaped individually")]
233+
#[allow(deprecated)]
234+
#[doc(hidden)]
225235
pub fn unescape_and_decode<B: BufRead>(&self, reader: &Reader<B>) -> Result<String> {
226236
self.do_unescape_and_decode_with_custom_entities(reader, None)
227237
}
@@ -240,7 +250,10 @@ impl<'a> BytesStart<'a> {
240250
/// # Pre-condition
241251
///
242252
/// The keys and values of `custom_entities`, if any, must be valid UTF-8.
243-
#[inline]
253+
#[cold]
254+
#[deprecated(note = "Tag names are never escaped. Attributes must be unescaped individually")]
255+
#[allow(deprecated)]
256+
#[doc(hidden)]
244257
pub fn unescape_and_decode_with_custom_entities<B: BufRead>(
245258
&self,
246259
reader: &Reader<B>,
@@ -250,7 +263,10 @@ impl<'a> BytesStart<'a> {
250263
}
251264

252265
#[cfg(feature = "encoding")]
253-
#[inline]
266+
#[cold]
267+
#[deprecated(note = "Tag names are never escaped. Attributes must be unescaped individually")]
268+
#[allow(deprecated)]
269+
#[doc(hidden)]
254270
fn do_unescape_and_decode_with_custom_entities<B: BufRead>(
255271
&self,
256272
reader: &Reader<B>,
@@ -263,7 +279,10 @@ impl<'a> BytesStart<'a> {
263279
}
264280

265281
#[cfg(not(feature = "encoding"))]
266-
#[inline]
282+
#[cold]
283+
#[deprecated(note = "Tag names are never escaped. Attributes must be unescaped individually")]
284+
#[allow(deprecated)]
285+
#[doc(hidden)]
267286
fn do_unescape_and_decode_with_custom_entities<B: BufRead>(
268287
&self,
269288
reader: &Reader<B>,

tests/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ fn fuzz_101() {
156156
loop {
157157
match reader.read_event(&mut buf) {
158158
Ok(Start(ref e)) | Ok(Empty(ref e)) => {
159+
#[allow(deprecated)]
159160
if e.unescaped().is_err() {
160161
break;
161162
}

0 commit comments

Comments
 (0)