Skip to content

Commit

Permalink
Merge pull request #6 from ardbiesheuvel/master
Browse files Browse the repository at this point in the history
aliases: strip NULL byte before returning the strings
  • Loading branch information
repnop committed Apr 1, 2022
2 parents fbcc7ff + a5ae918 commit 22f1282
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/standard_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<'b, 'a: 'b> Aliases<'b, 'a> {
self.node
.properties()
.find(|p| p.name == alias)
.and_then(|p| core::str::from_utf8(p.value).ok())
.and_then(|p| core::str::from_utf8(&p.value[..p.value.len() - 1]).ok())
}

/// Attempt to find the node specified by the given alias
Expand All @@ -107,7 +107,7 @@ impl<'b, 'a: 'b> Aliases<'b, 'a> {

/// Returns an iterator over all of the available aliases
pub fn all(self) -> impl Iterator<Item = (&'a str, &'a str)> + 'b {
self.node.properties().filter_map(|p| Some((p.name, core::str::from_utf8(p.value).ok()?)))
self.node.properties().filter_map(|p| Some((p.name, core::str::from_utf8(&p.value[..p.value.len() - 1]).ok()?)))
}
}

Expand Down

0 comments on commit 22f1282

Please sign in to comment.