Skip to content

Commit

Permalink
add file black list
Browse files Browse the repository at this point in the history
  • Loading branch information
ToDou committed Sep 5, 2016
1 parent 0924edf commit b9018d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,13 @@ public void call(Subscriber<? super String> subscriber) {
}
final InputStream finalStream = stream;
String[] names = mNode.name.split("\\.");
String jsFile = BrushMap.getJsFileForExtension(names[names.length - 1]);
String fileTypeName = names[names.length - 1];
if (BrushMap.isBlackFile(fileTypeName)) {
subscriber.onError(new Throwable("Can not open this file!"));
subscriber.onCompleted();
return;
}
String jsFile = BrushMap.getJsFileForExtension(fileTypeName);
if (jsFile == null) {
jsFile = "Txt";
}
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/com/loopeer/codereader/utils/BrushMap.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.loopeer.codereader.utils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
Expand All @@ -20,6 +21,13 @@ public BrushMap() {
}
}

public static final String[] FILE_BLACKLIST = new String[]{"hprof", "apk", "jar"};

public static boolean isBlackFile(String name) {
if (name != null) return Arrays.asList(FILE_BLACKLIST).contains(name.toLowerCase());
return false;
}

public static void init() {
List list = new ArrayList();
list.add("actionscript3");
Expand Down

0 comments on commit b9018d3

Please sign in to comment.