Fossil SCM
If file starts with UTF-32 BOM, always consider it binary without warning.
Commit
c209105f0fded945b10ae4cdc1e8594bfaba1e9c
Parent
6c417d8bf5f6d2e…
1 file changed
+6
-2
+6
-2
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -356,10 +356,14 @@ | ||
| 356 | 356 | } |
| 357 | 357 | /* Only accept UTF-16 BOM if the blob has an even number of bytes */ |
| 358 | 358 | if( (blob_size(pContent)<2) || (blob_size(pContent)&1) ) return 0; |
| 359 | 359 | c1 = *((unsigned short *)z); |
| 360 | 360 | if( (c1==0xfffe) || (c1==0xfeff) ){ |
| 361 | + if( blob_size(pContent)>=4 ){ | |
| 362 | + /* For UTF-32 BOM, always return 0. */ | |
| 363 | + if( ((unsigned short *)z)[1] == 0 ) return 0; | |
| 364 | + } | |
| 361 | 365 | return 2; |
| 362 | 366 | } |
| 363 | 367 | return 0; |
| 364 | 368 | } |
| 365 | 369 | |
| @@ -2324,11 +2328,11 @@ | ||
| 2324 | 2328 | if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1"; |
| 2325 | 2329 | iLimit = atoi(zLimit); |
| 2326 | 2330 | showLog = find_option("log",0,0)!=0; |
| 2327 | 2331 | fileVers = find_option("filevers",0,0)!=0; |
| 2328 | 2332 | db_must_be_within_tree(); |
| 2329 | - if (g.argc<3) { | |
| 2333 | + if( g.argc<3 ){ | |
| 2330 | 2334 | usage("FILENAME"); |
| 2331 | 2335 | } |
| 2332 | 2336 | file_tree_name(g.argv[2], &treename, 1); |
| 2333 | 2337 | zFilename = blob_str(&treename); |
| 2334 | 2338 | fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename); |
| @@ -2338,11 +2342,11 @@ | ||
| 2338 | 2342 | fid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFilename); |
| 2339 | 2343 | if( fid==0 ){ |
| 2340 | 2344 | fossil_fatal("not part of current checkout: %s", zFilename); |
| 2341 | 2345 | } |
| 2342 | 2346 | cid = db_lget_int("checkout", 0); |
| 2343 | - if (cid == 0){ | |
| 2347 | + if( cid == 0 ){ | |
| 2344 | 2348 | fossil_fatal("Not in a checkout"); |
| 2345 | 2349 | } |
| 2346 | 2350 | if( iLimit<=0 ) iLimit = 1000000000; |
| 2347 | 2351 | compute_direct_ancestors(cid, iLimit); |
| 2348 | 2352 | mid = db_int(0, "SELECT mlink.mid FROM mlink, ancestor " |
| 2349 | 2353 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -356,10 +356,14 @@ | |
| 356 | } |
| 357 | /* Only accept UTF-16 BOM if the blob has an even number of bytes */ |
| 358 | if( (blob_size(pContent)<2) || (blob_size(pContent)&1) ) return 0; |
| 359 | c1 = *((unsigned short *)z); |
| 360 | if( (c1==0xfffe) || (c1==0xfeff) ){ |
| 361 | return 2; |
| 362 | } |
| 363 | return 0; |
| 364 | } |
| 365 | |
| @@ -2324,11 +2328,11 @@ | |
| 2324 | if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1"; |
| 2325 | iLimit = atoi(zLimit); |
| 2326 | showLog = find_option("log",0,0)!=0; |
| 2327 | fileVers = find_option("filevers",0,0)!=0; |
| 2328 | db_must_be_within_tree(); |
| 2329 | if (g.argc<3) { |
| 2330 | usage("FILENAME"); |
| 2331 | } |
| 2332 | file_tree_name(g.argv[2], &treename, 1); |
| 2333 | zFilename = blob_str(&treename); |
| 2334 | fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename); |
| @@ -2338,11 +2342,11 @@ | |
| 2338 | fid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFilename); |
| 2339 | if( fid==0 ){ |
| 2340 | fossil_fatal("not part of current checkout: %s", zFilename); |
| 2341 | } |
| 2342 | cid = db_lget_int("checkout", 0); |
| 2343 | if (cid == 0){ |
| 2344 | fossil_fatal("Not in a checkout"); |
| 2345 | } |
| 2346 | if( iLimit<=0 ) iLimit = 1000000000; |
| 2347 | compute_direct_ancestors(cid, iLimit); |
| 2348 | mid = db_int(0, "SELECT mlink.mid FROM mlink, ancestor " |
| 2349 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -356,10 +356,14 @@ | |
| 356 | } |
| 357 | /* Only accept UTF-16 BOM if the blob has an even number of bytes */ |
| 358 | if( (blob_size(pContent)<2) || (blob_size(pContent)&1) ) return 0; |
| 359 | c1 = *((unsigned short *)z); |
| 360 | if( (c1==0xfffe) || (c1==0xfeff) ){ |
| 361 | if( blob_size(pContent)>=4 ){ |
| 362 | /* For UTF-32 BOM, always return 0. */ |
| 363 | if( ((unsigned short *)z)[1] == 0 ) return 0; |
| 364 | } |
| 365 | return 2; |
| 366 | } |
| 367 | return 0; |
| 368 | } |
| 369 | |
| @@ -2324,11 +2328,11 @@ | |
| 2328 | if( zLimit==0 || zLimit[0]==0 ) zLimit = "-1"; |
| 2329 | iLimit = atoi(zLimit); |
| 2330 | showLog = find_option("log",0,0)!=0; |
| 2331 | fileVers = find_option("filevers",0,0)!=0; |
| 2332 | db_must_be_within_tree(); |
| 2333 | if( g.argc<3 ){ |
| 2334 | usage("FILENAME"); |
| 2335 | } |
| 2336 | file_tree_name(g.argv[2], &treename, 1); |
| 2337 | zFilename = blob_str(&treename); |
| 2338 | fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename); |
| @@ -2338,11 +2342,11 @@ | |
| 2342 | fid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFilename); |
| 2343 | if( fid==0 ){ |
| 2344 | fossil_fatal("not part of current checkout: %s", zFilename); |
| 2345 | } |
| 2346 | cid = db_lget_int("checkout", 0); |
| 2347 | if( cid == 0 ){ |
| 2348 | fossil_fatal("Not in a checkout"); |
| 2349 | } |
| 2350 | if( iLimit<=0 ) iLimit = 1000000000; |
| 2351 | compute_direct_ancestors(cid, iLimit); |
| 2352 | mid = db_int(0, "SELECT mlink.mid FROM mlink, ancestor " |
| 2353 |