Skip to content

Commit 5a3e5b2

Browse files
authored
stringtable - fix escaped char (&) in stringtables (#845)
* stringtable - fix escaped char (`&`) in stringtables * Warn and skip file if phrase in unescapeable * fmt
1 parent cf3a9e4 commit 5a3e5b2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

libs/stringtable/src/rapify.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{Key, Project, ALL_LANGUAGES};
22
use hemtt_workspace::WorkspacePath;
3-
use tracing::trace;
3+
use tracing::{trace, warn};
44

55
#[derive(Default, Debug)]
66
pub struct XmlbLayout {
@@ -137,7 +137,12 @@ pub fn rapify(project: &Project) -> Option<XmlbLayout> {
137137
i32::try_from(translation.phrases.len()).expect("overflow"),
138138
);
139139
for phrase in &translation.phrases {
140-
write_string(&mut translation_buffer, phrase);
140+
let unescaped = quick_xml::escape::unescape(phrase.as_str());
141+
if unescaped.is_err() {
142+
warn!("failed to unescape stringtable entry [{}]", phrase);
143+
return None;
144+
}
145+
write_string(&mut translation_buffer, &unescaped.unwrap_or_default());
141146
}
142147
rolling_offset += translation_buffer.len();
143148
data.translations.push(translation_buffer);

0 commit comments

Comments
 (0)