Skip to content

Commit bb1df3a

Browse files
committed
Reuse existing method with does the same thing when encoding feature is disabled
1 parent 92e94c7 commit bb1df3a

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/events/attributes.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,12 @@ impl<'a> Attribute<'a> {
6363
///
6464
/// [`encoding`]: ../../index.html#encoding
6565
#[cfg(any(doc, not(feature = "encoding")))]
66+
#[inline]
6667
pub fn unescape_value_with<'entity>(
6768
&self,
6869
resolve_entity: impl FnMut(&str) -> Option<&'entity str>,
6970
) -> XmlResult<Cow<'a, str>> {
70-
// from_utf8 should never fail because content is always UTF-8 encoded
71-
let decoded = match &self.value {
72-
Cow::Borrowed(bytes) => Cow::Borrowed(std::str::from_utf8(bytes)?),
73-
// Convert to owned, because otherwise Cow will be bound with wrong lifetime
74-
Cow::Owned(bytes) => Cow::Owned(std::str::from_utf8(bytes)?.to_string()),
75-
};
76-
77-
match unescape_with(&decoded, resolve_entity)? {
78-
// Because result is borrowed, no replacements was done and we can use original string
79-
Cow::Borrowed(_) => Ok(decoded),
80-
Cow::Owned(s) => Ok(s.into()),
81-
}
71+
self.decode_and_unescape_value_with(Decoder::utf8(), resolve_entity)
8272
}
8373

8474
/// Decodes then unescapes the value.

0 commit comments

Comments
 (0)