summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2013-04-02 16:16:12 +0200
committerZolnai Tamás <zolnaitamas2000@gmail.com>2013-04-02 16:21:31 +0200
commit68c72dfb9db5c452bad13203699b17c4f4fcf6cc (patch)
tree8762a31846842b56395d10320d82d1733a2670cd /l10ntools
parent8d1765439caad42c8b679f94211c9bf022f51682 (diff)
Fix assertion in xmlparse and call this function with more care
Plus change range to [nStart,nEnd). Change-Id: I1570d07fdc90a6b2bdf3eef7914958212cbbaa87
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/source/xmlparse.cxx15
1 files changed, 9 insertions, 6 deletions
diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx
index 651a27a5fd21..954aed0bc40c 100644
--- a/l10ntools/source/xmlparse.cxx
+++ b/l10ntools/source/xmlparse.cxx
@@ -1180,9 +1180,10 @@ static icu::UnicodeString lcl_QuotRange(
const sal_Int32 nEnd, bool bInsideTag = false )
{
icu::UnicodeString sReturn;
+ assert( nStart < nEnd );
assert( nStart >= 0 );
- assert( nEnd < rString.length() );
- for (sal_Int32 i = nStart; i <= nEnd; ++i)
+ assert( nEnd <= rString.length() );
+ for (sal_Int32 i = nStart; i < nEnd; ++i)
{
switch (rString[i])
{
@@ -1258,20 +1259,22 @@ OUString XMLUtil::QuotHTML( const OUString &rString )
while( aRegexMatcher.find(nStartPos, nIcuErr) && nIcuErr == U_ZERO_ERROR )
{
nStartPos = aRegexMatcher.start(nIcuErr);
- sReturn.append(lcl_QuotRange(sSource, nEndPos, nStartPos-1));
+ if ( nEndPos < nStartPos )
+ sReturn.append(lcl_QuotRange(sSource, nEndPos, nStartPos));
nEndPos = aRegexMatcher.end(nIcuErr);
icu::UnicodeString sMatch = aRegexMatcher.group(nIcuErr);
if( lcl_isTag(sMatch) )
{
sReturn.append("<");
- sReturn.append(lcl_QuotRange(sSource, nStartPos+1, nEndPos-2, true));
+ sReturn.append(lcl_QuotRange(sSource, nStartPos+1, nEndPos-1, true));
sReturn.append(">");
}
else
- sReturn.append(lcl_QuotRange(sSource, nStartPos, nEndPos-1));
+ sReturn.append(lcl_QuotRange(sSource, nStartPos, nEndPos));
++nStartPos;
}
- sReturn.append(lcl_QuotRange(sSource, nEndPos, sSource.length()-1));
+ if( nEndPos < sSource.length() )
+ sReturn.append(lcl_QuotRange(sSource, nEndPos, sSource.length()));
sReturn.append('\0');
return OUString(reinterpret_cast<const sal_Unicode*>(sReturn.getBuffer()));
}