diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-08-07 16:15:21 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-09-28 08:48:34 +0100 |
commit | 1266f7fc2c2887b66fea5c765f69c8e760e29d41 (patch) | |
tree | 0e09b2eb7b31a5be3a0aba42da678578600d855f /l10ntools | |
parent | de2ae45914438582e84c7fbaa21ff4d271308587 (diff) |
we need to escape xml on export
Change-Id: I770e4e6b3b77892c3fe1ba1e55f3e6d5834dc6b7
Diffstat (limited to 'l10ntools')
-rw-r--r-- | l10ntools/source/uimerge.cxx | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/l10ntools/source/uimerge.cxx b/l10ntools/source/uimerge.cxx index cd7443e72725..7334b402dd94 100644 --- a/l10ntools/source/uimerge.cxx +++ b/l10ntools/source/uimerge.cxx @@ -9,6 +9,8 @@ #include <sal/main.h> +#include <rtl/strbuf.hxx> + #include <libxslt/transform.h> #include <libxslt/xslt.h> #include <libxslt/xsltutils.h> @@ -166,6 +168,52 @@ int extractTranslations() return 0; } +namespace +{ + rtl::OString QuotHTML(const rtl::OString &rString) + { + rtl::OStringBuffer sReturn; + for (sal_Int32 i = 0; i < rString.getLength(); ++i) { + switch (rString[i]) { + case '\\': + if (i < rString.getLength()) { + switch (rString[i + 1]) { + case '"': + case '<': + case '>': + case '\\': + ++i; + break; + } + } + // fall through + default: + sReturn.append(rString[i]); + break; + + case '<': + sReturn.append("<"); + break; + + case '>': + sReturn.append(">"); + break; + + case '"': + sReturn.append("""); + break; + + case '&': + if (rString.matchL(RTL_CONSTASCII_STRINGPARAM("&"), i)) + sReturn.append('&'); + else + sReturn.append(RTL_CONSTASCII_STRINGPARAM("&")); + break; + } + } + return sReturn.makeStringAndClear(); + } +} bool Merge( const rtl::OString &rSDFFile, @@ -211,7 +259,7 @@ bool Merge( aDestination << " <e " << "g=\"" << aI->second->sGID.getStr() << "\" " << "i=\"" << aI->second->sLID.getStr() << "\">" - << sOut.getStr() << "</e>\n"; + << QuotHTML(sOut).getStr() << "</e>\n"; } } |