Skip to content

Commit

Permalink
fix: handle invalid utf-8 with lossy conversion (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjsier authored Feb 17, 2023
1 parent b53faee commit fc664ea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ where
) -> Result<Element, Error> {
let mut element = Element::default();
let tag = start.local_name();
element.name = str::from_utf8(tag).unwrap().to_string();
element.name = String::from_utf8_lossy(tag).to_string();
element.attrs = attrs;
loop {
let mut e = self.reader.read_event(&mut self.buf)?;
Expand Down Expand Up @@ -1114,8 +1114,8 @@ where
.filter_map(Result::ok)
.map(|a| {
(
str::from_utf8(a.key).unwrap().to_string(),
str::from_utf8(&a.value).unwrap().to_string(),
String::from_utf8_lossy(a.key).to_string(),
String::from_utf8_lossy(&a.value).to_string(),
)
})
.collect()
Expand Down

0 comments on commit fc664ea

Please sign in to comment.