summaryrefslogtreecommitdiff
path: root/libwpd/libwpd-0.9.4.patch
blob: af0d3cf3b1a437b15fd0e4ebec48c1885d4972a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--- misc/libwpd-0.9.4/src/lib/WPXBinaryData.cpp	2011-10-28 15:37:48.000000000 +0200
+++ misc/build/libwpd-0.9.4/src/lib/WPXBinaryData.cpp	2012-06-09 00:02:43.293981048 +0200
@@ -174,7 +174,14 @@
 const WPXInputStream *WPXBinaryData::getDataStream() const
 {
 	if (m_binaryDataImpl->m_stream)
+	{
 		delete (m_binaryDataImpl->m_stream);
-	return ((m_binaryDataImpl->m_stream) = new WPXMemoryInputStream(&(m_binaryDataImpl->m_buf[0]), m_binaryDataImpl->m_buf.size()));
+		m_binaryDataImpl->m_stream = 0;
+	}
+	if (m_binaryDataImpl->m_buf.empty())
+		return 0;
+	m_binaryDataImpl->m_stream = new WPXMemoryInputStream(&(m_binaryDataImpl->m_buf[0]), m_binaryDataImpl->m_buf.size());
+	return m_binaryDataImpl->m_stream;
 }
+
 /* vim:set shiftwidth=4 softtabstop=4 noexpandtab: */
--- misc/libwpd-0.9.4/src/lib/WP42Heuristics.cpp
+++ misc/build/libwpd-0.9.4/src/lib/WP42Heuristics.cpp
@@ -70,6 +70,28 @@
 	WPXEncryption *encryption = 0;
 	try
 	{
+		// Disregard XML at least right away
+		if (readU8(input, 0) == '<' &&
+		    readU8(input, 0) == '?' &&
+		    readU8(input, 0) == 'x' &&
+		    readU8(input, 0) == 'm' &&
+		    readU8(input, 0) == 'l' &&
+		    readU8(input, 0) == ' ')
+			return WPD_CONFIDENCE_NONE;
+		input->seek(0, WPX_SEEK_SET);
+		
+		if (readU8(input, 0) == 0xEF &&
+		    readU8(input, 0) == 0xBB &&
+		    readU8(input, 0) == 0xBF &&
+		    readU8(input, 0) == '<' &&
+		    readU8(input, 0) == '?' &&
+		    readU8(input, 0) == 'x' &&
+		    readU8(input, 0) == 'm' &&
+		    readU8(input, 0) == 'l' &&
+		    readU8(input, 0) == ' ')
+			return WPD_CONFIDENCE_NONE;
+		input->seek(0, WPX_SEEK_SET);
+
 		if (readU8(input, 0) == 0xFE && readU8(input, 0) == 0xFF &&
 		        readU8(input, 0) == 0x61 && readU8(input, 0) == 0x61)
 		{