From 7dcbd57aa768d82a2daaccc707bb9f50404a34a3 Mon Sep 17 00:00:00 2001 From: Kirill Poljakov Date: Tue, 28 Feb 2023 12:44:41 +0300 Subject: [PATCH 1/2] Fix bug #61383 --- .../3dParty/html/css/src/CCompiledStyle.cpp | 2 +- Common/3dParty/html/css/src/ConstValues.h | 2 +- Common/3dParty/html/css/src/StaticFunctions.h | 20 +++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Common/3dParty/html/css/src/CCompiledStyle.cpp b/Common/3dParty/html/css/src/CCompiledStyle.cpp index 5852c560f7..d41d49415c 100644 --- a/Common/3dParty/html/css/src/CCompiledStyle.cpp +++ b/Common/3dParty/html/css/src/CCompiledStyle.cpp @@ -1282,7 +1282,7 @@ namespace NSCSS Scale(nValue, enScalingDirection); - sValueString += std::to_wstring(nValue); + sValueString += std::to_wstring(nValue) + sValueTemp.back(); } else sValueString += sValueTemp; diff --git a/Common/3dParty/html/css/src/ConstValues.h b/Common/3dParty/html/css/src/ConstValues.h index e0ba99e7e6..61fff36e64 100644 --- a/Common/3dParty/html/css/src/ConstValues.h +++ b/Common/3dParty/html/css/src/ConstValues.h @@ -2023,7 +2023,7 @@ namespace NSCSS if (sValue.empty()) return BorderSide(); - const std::vector arValues = NS_STATIC_FUNCTIONS::GetWordsW(sValue, L" "); + const std::vector arValues = NS_STATIC_FUNCTIONS::GetWordsW(NS_STATIC_FUNCTIONS::NormalizeRGB(sValue), L" "); BorderSide oBorderSide; for (std::wstring sValue : arValues) { diff --git a/Common/3dParty/html/css/src/StaticFunctions.h b/Common/3dParty/html/css/src/StaticFunctions.h index 50f85b922b..c984887374 100644 --- a/Common/3dParty/html/css/src/StaticFunctions.h +++ b/Common/3dParty/html/css/src/StaticFunctions.h @@ -315,6 +315,26 @@ namespace NSCSS return sValue.empty() ? false : std::all_of(sValue.begin(), sValue.end(), [] (const wchar_t& cChar) { return iswdigit(cChar); }); } + inline std::wstring NormalizeRGB(const std::wstring& wsValue) + { + std::wstring wsNewValue = wsValue; + + size_t unBegin = 0, unEnd; + + while (std::wstring::npos != (unBegin = wsNewValue.find(L"rgb(", unBegin))) + { + unEnd = wsNewValue.find(L")", unBegin); + + while ((unBegin = wsNewValue.find(L" ", unBegin)) != std::wstring::npos && unBegin < unEnd) + { + wsNewValue.replace(unBegin, 1, L","); + ++unBegin; + } + } + + return wsNewValue; + } + inline std::wstring ConvertRgbToHex(const std::wstring& sRgbValue) { size_t posFirst = sRgbValue.find_first_of(L"01234567890"); From 4aa56f8aa0041ac258dbea3263ba197f3e21ba46 Mon Sep 17 00:00:00 2001 From: Kirill Poljakov Date: Tue, 28 Feb 2023 13:22:12 +0300 Subject: [PATCH 2/2] For bug #61383 --- Common/3dParty/html/css/src/CCompiledStyle.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Common/3dParty/html/css/src/CCompiledStyle.cpp b/Common/3dParty/html/css/src/CCompiledStyle.cpp index d41d49415c..c62d997d61 100644 --- a/Common/3dParty/html/css/src/CCompiledStyle.cpp +++ b/Common/3dParty/html/css/src/CCompiledStyle.cpp @@ -1282,7 +1282,10 @@ namespace NSCSS Scale(nValue, enScalingDirection); - sValueString += std::to_wstring(nValue) + sValueTemp.back(); + sValueString += std::to_wstring(nValue); + + if (!iswdigit(sValueTemp.back())) + sValueString += sValueTemp.back(); } else sValueString += sValueTemp;