Skip to content

Commit

Permalink
stringtable - fix escaped char (&) in stringtables (#845)
Browse files Browse the repository at this point in the history
* stringtable - fix escaped char (`&`) in stringtables

* Warn and skip file if phrase in unescapeable

* fmt
  • Loading branch information
PabstMirror authored Dec 18, 2024
1 parent cf3a9e4 commit 5a3e5b2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions libs/stringtable/src/rapify.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{Key, Project, ALL_LANGUAGES};
use hemtt_workspace::WorkspacePath;
use tracing::trace;
use tracing::{trace, warn};

#[derive(Default, Debug)]
pub struct XmlbLayout {
Expand Down Expand Up @@ -137,7 +137,12 @@ pub fn rapify(project: &Project) -> Option<XmlbLayout> {
i32::try_from(translation.phrases.len()).expect("overflow"),
);
for phrase in &translation.phrases {
write_string(&mut translation_buffer, phrase);
let unescaped = quick_xml::escape::unescape(phrase.as_str());
if unescaped.is_err() {
warn!("failed to unescape stringtable entry [{}]", phrase);
return None;
}
write_string(&mut translation_buffer, &unescaped.unwrap_or_default());
}
rolling_offset += translation_buffer.len();
data.translations.push(translation_buffer);
Expand Down

0 comments on commit 5a3e5b2

Please sign in to comment.