summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--l10ntools/Executable_helpex.mk4
-rw-r--r--l10ntools/Executable_xrmex.mk4
-rw-r--r--l10ntools/source/helper.hxx20
-rw-r--r--l10ntools/source/helpmerge.cxx15
-rw-r--r--l10ntools/source/xrmmerge.cxx4
5 files changed, 42 insertions, 5 deletions
diff --git a/l10ntools/Executable_helpex.mk b/l10ntools/Executable_helpex.mk
index 22f2ae9288a4..b7e63100b351 100644
--- a/l10ntools/Executable_helpex.mk
+++ b/l10ntools/Executable_helpex.mk
@@ -49,4 +49,8 @@ $(eval $(call gb_Executable_add_exception_objects,helpex,\
l10ntools/source/helpmerge \
))
+$(eval $(call gb_Executable_use_externals,helpex,\
+ libxml2 \
+))
+
# vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/l10ntools/Executable_xrmex.mk b/l10ntools/Executable_xrmex.mk
index 02e776a2277b..73c56abe420a 100644
--- a/l10ntools/Executable_xrmex.mk
+++ b/l10ntools/Executable_xrmex.mk
@@ -50,4 +50,8 @@ $(eval $(call gb_Executable_add_exception_objects,xrmex,\
l10ntools/source/xrmmerge \
))
+$(eval $(call gb_Executable_use_externals,xrmex,\
+ libxml2 \
+))
+
# vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/l10ntools/source/helper.hxx b/l10ntools/source/helper.hxx
index cc33b71ff8ac..1e28aa6c4d50 100644
--- a/l10ntools/source/helper.hxx
+++ b/l10ntools/source/helper.hxx
@@ -35,6 +35,8 @@
#include <algorithm>
#include <cassert>
+#include <libxml/parser.h>
+
#include "rtl/string.hxx"
#include "rtl/ustring.hxx"
#include "sal/types.h"
@@ -100,6 +102,24 @@ inline sal_Int32 indexOfAnyAsciiL(
return -1;
}
+inline bool isWellFormedXML( OString const & text )
+{
+ xmlDocPtr doc;
+ OString content;
+ bool result = true;
+
+ content = "<root>";
+ content += text;
+ content += "</root>";
+ doc = xmlParseMemory(content.getStr(),(int)content.getLength());
+ if (doc == NULL) {
+ result = false;
+ }
+ xmlFreeDoc(doc);
+ xmlCleanupParser();
+ return result;
+}
+
template< typename T > inline T abbreviate(
T const & text, sal_Int32 start, sal_Int32 length)
{
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index 05b3800bbc81..aab255f75a05 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -341,7 +341,7 @@ void HelpParser::MakeDir(const rtl::OString& rPath)
void HelpParser::ProcessHelp( LangHashMap* aLangHM , const rtl::OString& sCur , ResData *pResData , MergeDataFile& aMergeDataFile ){
XMLElement* pXMLElement = NULL;
- PFormEntrys *pEntrys = NULL;
+ PFormEntrys *pEntrys = NULL;
XMLData *data = NULL;
rtl::OString sLId;
@@ -379,9 +379,16 @@ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const rtl::OString& sCur ,
while ( (nPreSpaces < nLen) && (*(sSourceText.getStr()+nPreSpaces) == ' ') )
nPreSpaces++;
pEntrys->GetText( sNewText, STRING_TYP_TEXT, sCur , true );
- rtl::OUString sNewdata(
- sSourceText.copy(0,nPreSpaces) +
- rtl::OStringToOUString(sNewText, RTL_TEXTENCODING_UTF8));
+ OUString sNewdata;
+ if (helper::isWellFormedXML(sNewText))
+ {
+ sNewdata = sSourceText.copy(0,nPreSpaces) +
+ rtl::OStringToOUString(sNewText, RTL_TEXTENCODING_UTF8);
+ }
+ else
+ {
+ sNewdata = sSourceText;
+ }
if (!sNewdata.isEmpty())
{
if( pXMLElement != NULL )
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index a3eb0e5418ee..b4868f5f8623 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -27,6 +27,7 @@
#include "export.hxx"
#include "xrmmerge.hxx"
#include "tokens.h"
+#include "helper.hxx"
#include <iostream>
#include <fstream>
#include <vector>
@@ -606,7 +607,8 @@ void XRMResMerge::WorkOnText(
if ( Export::isAllowed( sLang ) &&
( pEntrys->GetText(
sContent, STRING_TYP_TEXT, sLang )) &&
- ( sContent != "-" ) && !sContent.isEmpty())
+ ( sContent != "-" ) && !sContent.isEmpty() &&
+ helper::isWellFormedXML( sContent ))
{
rText = sContent;