From 645184f11e45d2ac76f0e608598bed6f106164c0 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Thu, 7 Jun 2018 22:30:53 +0100 Subject: [PATCH] [ui] fix some unwanted display of LTR or RTL strings * Some English messages could appear RTL in the log * Folder paths with RTL strings could appear scrambled in the UI --- src/localization.c | 4 ++-- src/rufus.rc | 10 +++++----- src/stdfn.c | 12 +++++++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/localization.c b/src/localization.c index ad9289a8..1d54d958 100644 --- a/src/localization.c +++ b/src/localization.c @@ -380,7 +380,7 @@ char* lmprintf(uint32_t msg_id, ...) if (format == NULL) { safe_sprintf(buf[buf_id], LOC_MESSAGE_SIZE-1, "MSG_%03d UNTRANSLATED", msg_id - MSG_000); } else { - if (right_to_left_mode) { + if (right_to_left_mode && (msg_table != default_msg_table)) { if (is_rtf) { safe_strcpy(&buf[buf_id][pos], LOC_MESSAGE_SIZE - 1, "\\rtlch"); pos += 6; @@ -391,7 +391,7 @@ char* lmprintf(uint32_t msg_id, ...) va_start(args, msg_id); safe_vsnprintf(&buf[buf_id][pos], LOC_MESSAGE_SIZE- 1 - 2*pos, format, args); va_end(args); - if (right_to_left_mode) { + if (right_to_left_mode && (msg_table != default_msg_table)) { safe_strcat(buf[buf_id], LOC_MESSAGE_SIZE - 1, POP_DIRECTIONAL_FORMATTING); if (is_rtf) safe_strcat(buf[buf_id], LOC_MESSAGE_SIZE - 1, "\\ltrch"); diff --git a/src/rufus.rc b/src/rufus.rc index e9ecdf66..4accdfad 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 3.1.1311" +CAPTION "Rufus 3.1.1312" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -389,8 +389,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,1,1311,0 - PRODUCTVERSION 3,1,1311,0 + FILEVERSION 3,1,1312,0 + PRODUCTVERSION 3,1,1312,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -407,13 +407,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.1.1311" + VALUE "FileVersion", "3.1.1312" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.1.1311" + VALUE "ProductVersion", "3.1.1312" END END BLOCK "VarFileInfo" diff --git a/src/stdfn.c b/src/stdfn.c index 6f0890b6..36896eb8 100644 --- a/src/stdfn.c +++ b/src/stdfn.c @@ -463,6 +463,7 @@ BOOL FileIO(BOOL save, char* path, char** buffer, DWORD* size) HANDLE handle; BOOL r; BOOL ret = FALSE; + char* ltr_path; // Change the owner from admin to regular user sid = GetSID(); @@ -505,7 +506,16 @@ BOOL FileIO(BOOL save, char* path, char** buffer, DWORD* size) goto out; } - PrintInfoDebug(0, save?MSG_216:MSG_215, path); + // Ensure that the path is always displayed LTR + // Use of sizeof gets us the extra char needed for NUL terminator + ltr_path = malloc(safe_strlen(path) + sizeof(LEFT_TO_RIGHT_EMBEDDING) + sizeof(POP_DIRECTIONAL_FORMATTING)); + if (ltr_path == NULL) { + PrintInfoDebug(0, save ? MSG_216 : MSG_215, path); + } else { + sprintf(ltr_path, "%s%s%s", LEFT_TO_RIGHT_EMBEDDING, path, POP_DIRECTIONAL_FORMATTING); + PrintInfoDebug(0, save ? MSG_216 : MSG_215, ltr_path); + free(ltr_path); + } ret = TRUE; out: