From 57d0104c01a7978e262b66a235665dcb2a865154 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 22 Oct 2012 20:05:42 +0000 Subject: [PATCH] - unescape special html entities when pulling down lng files from transifex - do not show pw when showing ini settings on commandline --- source/glest_game/main/main.cpp | 7 +- source/glest_game/menu/menu_state_options.cpp | 3 +- .../include/platform/common/platform_common.h | 1 + .../platform/common/platform_common.cpp | 66 +++++++++++++++++++ 4 files changed, 75 insertions(+), 2 deletions(-) diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 47244f55..21663ff8 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -2587,7 +2587,12 @@ void ShowINISettings(int argc, char **argv,Config &config,Config &configKeys) { printf("\t"); } - printf("Value [%s]\n",nameValue.second.c_str()); + string displayValue = nameValue.second; + if(nameValue.first == "TranslationGetURLPassword") { + displayValue = "*****"; + } + + printf("Value [%s]\n",displayValue.c_str()); } } diff --git a/source/glest_game/menu/menu_state_options.cpp b/source/glest_game/menu/menu_state_options.cpp index 0db9929c..0bd02061 100644 --- a/source/glest_game/menu/menu_state_options.cpp +++ b/source/glest_game/menu/menu_state_options.cpp @@ -1241,7 +1241,8 @@ void MenuStateOptions::mouseClick(int x, int y, MouseButton mouseButton){ replaceAll(fileData,"\\n","\n"); replaceAll(fileData,"$requires-newline$","\\n"); - replaceAll(fileData,""","\""); + //replaceAll(fileData,""","\""); + replaceAllHTMLEntities(fileData); printf("PARSED Language text\n[%s]\n",fileData.c_str()); diff --git a/source/shared_lib/include/platform/common/platform_common.h b/source/shared_lib/include/platform/common/platform_common.h index 841c6976..9708a2bb 100644 --- a/source/shared_lib/include/platform/common/platform_common.h +++ b/source/shared_lib/include/platform/common/platform_common.h @@ -224,6 +224,7 @@ void trimPathWithStartingSlash(string &path); void updatePathClimbingParts(string &path); string formatPath(string path); +string replaceAllHTMLEntities(string& context); string replaceAll(string& context, const string& from, const string& to); vector replaceAllBetweenTokens(vector& context, const string &startToken, const string &endToken, const string &newText, bool removeTokens=true); string replaceAllBetweenTokens(string& context, const string &startToken, const string &endToken, const string &newText, bool removeTokens=true); diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index ef2aa849..6d115fcf 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -1795,6 +1795,72 @@ bool isKeyDown(int virtualKey) { return false; } +string replaceAllHTMLEntities(string& context) { +// quotation mark = APL quote " " " " " " +// ampersand & & & & & & +// less-than sign < < < < < < +// greater-than sign > > > > > > +// Latin capital ligature OE Œ Œ Œ Œ Œ Œ +// Latin small ligature oe œ œ œ œ œ œ +// Latin capital letter S with caron Š Š Š Š Š Š +// Latin small letter s with caron š š š š š š +// Latin capital letter Y with diaeresis Ÿ Ÿ Ÿ Ÿ Ÿ Ÿ +// modifier letter circumflex accent ˆ ˆ ˆ ˆ ˆ ˆ +// small tilde ˜ ˜ ˜ ˜ ˜ ˜ +// en space       +// em space       +// thin space       +// zero width non-joiner ‌ ‌ ‌ ‌ ‌ ‌ +// zero width joiner ‍ ‍ ‍ ‍ ‍ ‍ +// left-to-right mark ‎ ‎ ‎ ‎ ‎ ‎ +// right-to-left mark ‏ ‏ ‏ ‏ ‏ ‏ +// en dash – – – – – – +// em dash — — — — — — +// left single quotation mark ‘ ‘ ‘ ‘ ‘ ‘ +// right single quotation mark ’ ’ ’ ’ ’ ’ +// single low-9 quotation mark ‚ ‚ ‚ ‚ ‚ ‚ +// left double quotation mark “ “ “ “ “ “ +// right double quotation mark ” ” ” ” ” ” +// double low-9 quotation mark „ „ „ „ „ „ +// dagger † † † † † † +// double dagger ‡ ‡ ‡ ‡ ‡ ‡ +// per mille sign ‰ ‰ ‰ ‰ ‰ ‰ +// single left-pointing angle quotation mark ‹ ‹ ‹ ‹ ‹ ‹ +// single right-pointing angle quotation mark › › › › › › +// euro sign € € € € € € + + replaceAll(context,""","\""); + replaceAll(context,"&","&"); + replaceAll(context,"<","<"); + replaceAll(context,">",">"); + replaceAll(context,"Œ","Œ"); + replaceAll(context,"œ","œ"); + replaceAll(context,"Š","Š"); + replaceAll(context,"š","š"); + replaceAll(context,"Ÿ","Ÿ"); + replaceAll(context,"ˆ","ˆ"); + replaceAll(context,"˜","˜"); + replaceAll(context," "," "); + replaceAll(context," "," "); + replaceAll(context," "," "); + replaceAll(context,"–","-"); + replaceAll(context,"—","-"); + replaceAll(context,"‘","‘"); + replaceAll(context,"’","’"); + replaceAll(context,"‚","‚"); + replaceAll(context,"“","“"); + replaceAll(context,"”","”"); + replaceAll(context,"„","„"); + replaceAll(context,"†","†"); + replaceAll(context,"‡","‡"); + replaceAll(context,"‰","‰"); + replaceAll(context,"‹","‹"); + replaceAll(context,"›","›"); + replaceAll(context,"€","€"); + + return context; +} + string replaceAll(string& context, const string& from, const string& to) { size_t lookHere = 0; size_t foundHere = 0;