summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorJose <pepone@users.noreply.github.com>2023-02-21 13:15:16 +0100
committerGitHub <noreply@github.com>2023-02-21 13:15:16 +0100
commit0794c25efdc9fb398d7836baac085e5ee182c848 (patch)
treeb3cfbac7d9a02162474f51160cfd139675f3cedb /cpp/src
parentHandle missing required permission in Android test Controller (diff)
downloadice-0794c25efdc9fb398d7836baac085e5ee182c848.tar.bz2
ice-0794c25efdc9fb398d7836baac085e5ee182c848.tar.xz
ice-0794c25efdc9fb398d7836baac085e5ee182c848.zip
slice2cs HTML tag strip (#1433)
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/slice2cs/Gen.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 14024ff60d2..b4ff72c7e2c 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -1304,11 +1304,34 @@ Slice::CsVisitor::editMarkup(const string& s)
if(pos != string::npos)
{
string::size_type endpos = result.find('>', pos);
- if(endpos == string::npos)
+ string::size_type wspos = result.find(' ', pos);
+ if(endpos == string::npos && wspos == string::npos)
{
break;
}
- result.erase(pos, endpos - pos + 1);
+
+ if(wspos < endpos)
+ {
+ // If we found a whitespace before the end tag marker '>', The '<' char doesn't correspond to the start
+ // of a HTML tag, and we replace it with &lt; escape code.
+ result.replace(pos, 1, "&lt;", 4);
+ }
+ else
+ {
+ result.erase(pos, endpos - pos + 1);
+ }
+ }
+ }
+ while(pos != string::npos);
+
+ // replace remaining '>' chars with '&gt;' escape code, tags have been already strip above.
+ pos = 0;
+ do
+ {
+ pos = result.find('>', pos);
+ if(pos != string::npos)
+ {
+ result.replace(pos, 1, "&gt;", 4);
}
}
while(pos != string::npos);