summaryrefslogtreecommitdiff
path: root/tools/source/stream/stream.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'tools/source/stream/stream.cxx')
-rw-r--r--tools/source/stream/stream.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index ee1c513adba6..ac660cbffbcc 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1108,6 +1108,9 @@ sal_Bool SvStream::ReadCsvLine( String& rStr, sal_Bool bEmbeddedLineBreak,
if (bEmbeddedLineBreak)
{
+ // See if the separator(s) include tab.
+ bool bTabSep = lcl_UnicodeStrChr(pSeps, '\t') != NULL;
+
const sal_Unicode* pSeps = rFieldSeparators.GetBuffer();
xub_StrLen nLastOffset = 0;
xub_StrLen nQuotes = 0;
@@ -1121,6 +1124,16 @@ sal_Bool SvStream::ReadCsvLine( String& rStr, sal_Bool bEmbeddedLineBreak,
{
if (nQuotes)
{
+ if (bTabSep && *p == '\t')
+ {
+ // When tab-delimited, tab char ends quoted sequence
+ // even if we haven't reached the end quote. Doing
+ // this helps keep mal-formed rows from damaging
+ // other, well-formed rows.
+ nQuotes = 0;
+ break;
+ }
+
if (*p == cFieldQuote && !bBackslashEscaped)
++nQuotes;
else if (bAllowBackslashEscape)