diff options
Diffstat (limited to 'writerfilter/source/rtftok')
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.cxx | 17 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtfdocumentimpl.hxx | 6 | ||||
-rw-r--r-- | writerfilter/source/rtftok/rtftokenizer.cxx | 10 |
3 files changed, 18 insertions, 15 deletions
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index c396f7fb1787..f2873ecf97b8 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -1181,7 +1181,7 @@ RTFError RTFDocumentImpl::resolveChars(char ch) return RTFError::OK; } - OStringBuffer aBuf; + OStringBuffer aBuf(512); bool bUnicodeChecked = false; bool bSkipped = false; @@ -1275,8 +1275,9 @@ RTFError RTFDocumentImpl::resolveChars(char ch) return RTFError::OK; } - OUString aOUStr(OStringToOUString(aStr, m_aStates.top().getCurrentEncoding())); - SAL_INFO("writerfilter.rtf", "RTFDocumentImpl::resolveChars: collected '" << aOUStr << "'"); + SAL_INFO("writerfilter.rtf", + "RTFDocumentImpl::resolveChars: collected '" + << OStringToOUString(aStr, m_aStates.top().getCurrentEncoding()) << "'"); if (m_aStates.top().getDestination() == Destination::COLORTABLE) { @@ -2323,7 +2324,7 @@ RTFError RTFDocumentImpl::popState() { OUString aOrig = pValue->getString(); - OUStringBuffer aBuf; + OUStringBuffer aBuf(aOrig.getLength() * 2); sal_Int32 nReplaces = 1; for (int i = 0; i < aOrig.getLength(); i++) { @@ -2337,7 +2338,7 @@ RTFError RTFDocumentImpl::popState() - aState.getLevelNumbers().size())); } else - aBuf.append(std::u16string_view(aOrig).substr(i, 1)); + aBuf.append(aOrig[i]); } pValue->setString(aBuf.makeStringAndClear()); @@ -3566,7 +3567,8 @@ void RTFDocumentImpl::checkUnicode(bool bUnicode, bool bHex) { if (bUnicode && !m_aUnicodeBuffer.isEmpty()) { - OUString aString = m_aUnicodeBuffer.makeStringAndClear(); + OUString aString = m_aUnicodeBuffer.toString(); + m_aUnicodeBuffer.setLength(0); text(aString); } if (bHex && !m_aHexBuffer.isEmpty()) @@ -3575,7 +3577,8 @@ void RTFDocumentImpl::checkUnicode(bool bUnicode, bool bHex) if (m_aStates.top().getDestination() == Destination::FONTENTRY && m_aStates.top().getCurrentEncoding() == RTL_TEXTENCODING_SYMBOL) nEncoding = RTL_TEXTENCODING_MS_1252; - OUString aString = OStringToOUString(m_aHexBuffer.makeStringAndClear(), nEncoding); + OUString aString = OStringToOUString(m_aHexBuffer.toString(), nEncoding); + m_aHexBuffer.setLength(0); text(aString); } } diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx index 5ee84d791e5c..360c753172b7 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx @@ -590,7 +590,7 @@ private: sal_uInt16 m_nMinute; /// Text from special destinations. - OUStringBuffer m_aDestinationText; + OUStringBuffer m_aDestinationText{ 512 }; /// point to the buffer of the current destination OUStringBuffer* m_pCurrentDestinationText; @@ -931,9 +931,9 @@ private: /// For the INCLUDEPICTURE field's argument. OUString m_aPicturePath; // Unicode characters are collected here so we don't have to send them one by one. - OUStringBuffer m_aUnicodeBuffer; + OUStringBuffer m_aUnicodeBuffer{ 512 }; /// Same for hex characters. - OStringBuffer m_aHexBuffer; + OStringBuffer m_aHexBuffer{ 512 }; /// Formula import. oox::formulaimport::XmlStreamBuilder m_aMathBuffer; /// Normal text property, that is math italic and math spacing are not applied to the current run. diff --git a/writerfilter/source/rtftok/rtftokenizer.cxx b/writerfilter/source/rtftok/rtftokenizer.cxx index 03d5d0d3e56a..0b39232cd983 100644 --- a/writerfilter/source/rtftok/rtftokenizer.cxx +++ b/writerfilter/source/rtftok/rtftokenizer.cxx @@ -182,7 +182,7 @@ void RTFTokenizer::popGroup() { m_nGroup--; } RTFError RTFTokenizer::resolveKeyword() { char ch; - OStringBuffer aBuf; + OStringBuffer aBuf(32); bool bNeg = false; bool bParam = false; int nParam = 0; @@ -202,6 +202,10 @@ RTFError RTFTokenizer::resolveKeyword() while (rtl::isAsciiAlpha(static_cast<unsigned char>(ch))) { aBuf.append(ch); + if (aBuf.getLength() > 32) + // See RTF spec v1.9.1, page 7 + // A control word's name cannot be longer than 32 letters. + throw io::BufferSizeExceededException(); Strm().ReadChar(ch); if (Strm().eof()) { @@ -209,10 +213,6 @@ RTFError RTFTokenizer::resolveKeyword() break; } } - if (aBuf.getLength() > 32) - // See RTF spec v1.9.1, page 7 - // A control word's name cannot be longer than 32 letters. - throw io::BufferSizeExceededException(); if (ch == '-') { |