mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-25 19:17:06 -06:00
Merge pull request #1353
This commit is contained in:
@@ -308,7 +308,10 @@ fn decode_text(raw: &str) -> String {
|
||||
while let Some(at) = rest.find('&') {
|
||||
out.push_str(&collapse_space(&rest[..at]));
|
||||
rest = &rest[at..];
|
||||
let search_window = rest.len().min(32);
|
||||
let mut search_window = rest.len().min(32);
|
||||
while !rest.is_char_boundary(search_window) {
|
||||
search_window -= 1;
|
||||
}
|
||||
let Some(end) = rest[..search_window].find(';') else {
|
||||
out.push('&');
|
||||
rest = &rest[1..];
|
||||
@@ -365,6 +368,14 @@ fn fold(s: &str) -> String {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn multibyte_after_ampersand_is_kept() {
|
||||
let text = "é".repeat(20);
|
||||
assert_eq!(decode_text(&format!("R&D {text}")), format!("R&D {text}"));
|
||||
let cjk = "漢".repeat(20);
|
||||
assert_eq!(decode_text(&format!("&{cjk}")), format!("&{cjk}"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn signed_numeric_entities_are_kept_as_typed() {
|
||||
assert_eq!(decode_text("a&#+65;b"), "a&#+65;b");
|
||||
|
||||
Reference in New Issue
Block a user