[Libreoffice-commits] core.git: filter/source
Maxim Monastirsky
momonasmon at gmail.com
Sun Dec 8 15:50:28 PST 2013
filter/source/xmlfilterdetect/filterdetect.cxx | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
New commits:
commit f38277dc0337df15f3ea689096a2c18a03354a61
Author: Maxim Monastirsky <momonasmon at gmail.com>
Date: Thu Dec 5 17:56:17 2013 +0200
fdo#46262 Detect XML files with UTF-8 BOM
Also convert sal_Char (deprecated) -> char
Change-Id: Ibf66f6a9ea751bab96f43671fe95a835c073d9e0
Reviewed-on: https://gerrit.libreoffice.org/6942
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/filter/source/xmlfilterdetect/filterdetect.cxx b/filter/source/xmlfilterdetect/filterdetect.cxx
index 60681d2..27f173a 100644
--- a/filter/source/xmlfilterdetect/filterdetect.cxx
+++ b/filter/source/xmlfilterdetect/filterdetect.cxx
@@ -78,10 +78,24 @@ bool isXMLStream(const OString& aHeaderStrm)
size_t n = aHeaderStrm.getLength();
size_t i = 0;
+ // Skip UTF-8 BOM
+ const char sBOM[] = {(char)0xEF, (char)0xBB, (char)0xBF};
+ for (i = 0; i < n; ++i, ++p)
+ {
+ if (i < 3 && *p == sBOM[i])
+ continue;
+ else if (i == 3 || i == 0)
+ break;
+ else if (i > 0)
+ return false;
+ }
+
+ n -= i;
+
// Skip all preceding blank characters.
for (i = 0; i < n; ++i, ++p)
{
- sal_Char c = *p;
+ char c = *p;
if (c == ' ' || c == '\n' || c == '\t')
continue;
break;
More information about the Libreoffice-commits
mailing list