From efa167e2b4d07c0e197344d0aa38d5a75aed801c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 30 Apr 2023 10:39:21 +0200 Subject: [PATCH] Accept number format strings like "%i%%" (results in "30%" if i == 30). Fallout from #17349 --- Common/UI/PopupScreens.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Common/UI/PopupScreens.cpp b/Common/UI/PopupScreens.cpp index 1c4b2277bc..3ed8f21d8b 100644 --- a/Common/UI/PopupScreens.cpp +++ b/Common/UI/PopupScreens.cpp @@ -197,11 +197,16 @@ static bool IsValidNumberFormatString(const std::string &s) { size_t percentCount = 0; for (int i = 0; i < (int)s.size(); i++) { if (s[i] == '%') { - percentCount++; if (i < s.size() - 1) { - if (s[i] == 's') + if (s[i + 1] == 's') return false; + if (s[i + 1] == '%') { + // Next is another % sign, so it's an escape to emit a % sign, which is fine. + i++; + continue; + } } + percentCount++; } } return percentCount == 1;