Page MenuHomePhabricator

Force source code to show diffs in Diffusion instead of binary

Authored By
matelich
Jun 5 2015, 9:38 PM
Size
1 KB
Referenced Files
None
Subscribers
None

Force source code to show diffs in Diffusion instead of binary

diff --git a/src/parser/ArcanistDiffParser.php b/src/parser/ArcanistDiffParser.php
index 0e9627b..54da690 100644
--- a/src/parser/ArcanistDiffParser.php
+++ b/src/parser/ArcanistDiffParser.php
@@ -1020,6 +1020,16 @@ final class ArcanistDiffParser {
}
+ //For files we think are binary, double-check they're not using extensions defined as code
+ //backwards is slightly faster and way more fun
+ if($is_binary) {
+ $back_path = substr(strrev($change->getCurrentPath()), 0, 5); //5 == max of non_binary strlens
+ $reversed_non_binary_file_extensions = array("pph.","h.","php.","ppc.","lni.","sc.","lmax.","iu.");
+ foreach ($reversed_non_binary_file_extensions as $rev_ext) {
+ if(stripos($back_path, $rev_ext) === 0){
+ $is_binary = false;
+ break;
+ }
+ }
+ }
if ($is_binary) {
// SVN happily treats binary files which aren't marked with the right
// mime type as text files. Detect that junk here and mark the file

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/2c/4g/xwyxew2bdeqxpqhj
Default Alt Text
Force source code to show diffs in Diffusion instead of binary (1 KB)

Event Timeline