Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions crates/socket-patch-core/src/formats/nuget/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,20 @@ fn decode_entities(raw: &str) -> String {
out
}

/// Encode `value` for a double-quoted attribute: the inverse of
/// [`parse_config`]'s decoding, so a key read as `a&b` is written back as
/// `a&b` and keeps its identity.
pub(crate) fn xml_attribute(value: &str) -> String {
value
.replace('&', "&")
.replace('"', """)
.replace('<', "&lt;")
// Literal XML attribute whitespace would be normalized to spaces.
.replace('\t', "&#x9;")
.replace('\n', "&#xA;")
.replace('\r', "&#xD;")
}

#[cfg(test)]
mod tests {
#[test]
Expand Down
Loading
Loading