KMimeType::isBufferBinaryData() is broken

Andreas Pakulat apaku at gmx.de
Sat May 5 12:04:27 BST 2007


Hi,

just found out that isBufferBinaryData fails to recognize plain/text
when there's a linefeed in the first 32 bytes. IMHO the check should
check for bytes in the range 00-0A, 0B-0C and 0E-1F, i.e. leave out
linefeed and carriage return. Those two ascii control characters are
valid in plain/text.

The attached patch does this, objections against committing?

Andreas

-- 
Next Friday will not be your lucky day.  As a matter of fact, you don't
have a lucky day this year.
-------------- next part --------------
Index: kmimetype.cpp
===================================================================
--- kmimetype.cpp	(Revision 660342)
+++ kmimetype.cpp	(Arbeitskopie)
@@ -167,7 +167,8 @@ bool KMimeType::isBufferBinaryData(const
     const char* p = data.data();
     const int end = qMin(32, data.size());
     for (int i = 0; i < end; ++i) {
-        if (p[i] < 32) // ASCII control character
+        char c = p[i];
+        if (p[i] < 32 && p[i] != 10 && p[i] != 13) // ASCII control character
             return true;
     }
     return false;


More information about the kde-core-devel mailing list