diff --git a/simgear/misc/strutils.cxx b/simgear/misc/strutils.cxx index 405a980c..d3a483db 100644 --- a/simgear/misc/strutils.cxx +++ b/simgear/misc/strutils.cxx @@ -674,7 +674,7 @@ std::string unescape(const char* s) } else if (*s >= '0' && *s <= '7') { int v = *s++ - '0'; - for (int i = 0; i < 3 && *s >= '0' && *s <= '7'; i++, s++) + for (int i = 0; i < 2 && *s >= '0' && *s <= '7'; i++, s++) v = v * 8 + *s - '0'; r += v; continue; diff --git a/simgear/misc/strutils_test.cxx b/simgear/misc/strutils_test.cxx index 073d474c..d2c19cd9 100644 --- a/simgear/misc/strutils_test.cxx +++ b/simgear/misc/strutils_test.cxx @@ -142,6 +142,8 @@ void test_split() void test_unescape() { SG_CHECK_EQUAL(strutils::unescape("\\ \\n\\t\\x41\\117a"), " \n\tAOa"); + // Two chars: '\033' (ESC) followed by '2' + SG_CHECK_EQUAL(strutils::unescape("\\0332"), "\0332"); } void test_compare_versions()