subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1204167 - /subversion/trunk/subversion/libsvn_subr/io.c
Date Sun, 20 Nov 2011 13:35:00 GMT
Author: stsp
Date: Sun Nov 20 13:35:00 2011
New Revision: 1204167

URL: http://svn.apache.org/viewvc?rev=1204167&view=rev
Log:
Fix issue #4064, "UTF-8 files containing only a byte order mark are added
as binary".

Special-case empty UTF-8 files which have a UTF-8 BOM. This prevents such
files from being considered binary.

* subversion/libsvn_subr/io.c
  (svn_io_is_binary_data): Return FALSE if the data contains only a UTF-8 BOM.

Reported by: Tomáš Bihary

Modified:
    subversion/trunk/subversion/libsvn_subr/io.c

Modified: subversion/trunk/subversion/libsvn_subr/io.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/io.c?rev=1204167&r1=1204166&r2=1204167&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/io.c (original)
+++ subversion/trunk/subversion/libsvn_subr/io.c Sun Nov 20 13:35:00 2011
@@ -2980,6 +2980,13 @@ svn_io_is_binary_data(const void *data, 
 {
   const unsigned char *buf = data;
 
+  if (len == 3 && buf[0] == 0xEF && buf[1] == 0xBB && buf[2] == 0xBF)
+    {
+      /* This is an empty UTF-8 file which only contains the UTF-8 BOM.
+       * Treat it as plain text. */
+      return FALSE;
+    }
+
   /* Right now, this function is going to be really stupid.  It's
      going to examine the block of data, and make sure that 15%
      of the bytes are such that their value is in the ranges 0x07-0x0D



Mime
View raw message