Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/org/adblockplus/android/AdblockPlus.java

Issue 6227976249147392: Fix whitelisting issues (Closed)
Patch Set: Created Nov. 29, 2013, 3:31 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/org/adblockplus/android/AdblockPlus.java
===================================================================
--- a/src/org/adblockplus/android/AdblockPlus.java
+++ b/src/org/adblockplus/android/AdblockPlus.java
@@ -61,6 +61,7 @@
private final static Pattern RE_CSS = Pattern.compile(".*\\.css$", Pattern.CASE_INSENSITIVE);
private final static Pattern RE_IMAGE = Pattern.compile(".*\\.(?:gif|png|jpe?g|bmp|ico)$", Pattern.CASE_INSENSITIVE);
private final static Pattern RE_FONT = Pattern.compile(".*\\.(?:ttf|woff)$", Pattern.CASE_INSENSITIVE);
+ private final static Pattern RE_HTML = Pattern.compile(".*\\.html?$", Pattern.CASE_INSENSITIVE);
/**
* Broadcasted when filtering is enabled or disabled.
@@ -371,8 +372,9 @@
*/
public boolean matches(String url, String query, String referrer, String accept)
{
+ final String fullUrl = !"".equals(query) ? url + "?" + query : url;
if (referrer != null)
- referrerMapping.put(url, referrer);
+ referrerMapping.put(fullUrl, referrer);
if (!filteringEnabled)
return false;
@@ -385,6 +387,8 @@
contentType = "STYLESHEET";
else if (accept.contains("image/*"))
contentType = "IMAGE";
+ else if (accept.contains("text/html"))
+ contentType = "SUBDOCUMENT";
}
if (contentType == null)
@@ -397,17 +401,16 @@
contentType = "IMAGE";
else if (RE_FONT.matcher(url).matches())
contentType = "FONT";
+ else if (RE_HTML.matcher(url).matches())
+ contentType = "SUBDOCUMENT";
}
if (contentType == null)
contentType = "OTHER";
- if (!"".equals(query))
- url = url + "?" + query;
-
final List<String> referrerChain = buildReferrerChain(referrer);
- Log.d("Referrer chain", url + ": " + referrerChain.toString());
+ Log.d("Referrer chain", fullUrl + ": " + referrerChain.toString());
String[] referrerChainArray = referrerChain.toArray(new String[referrerChain.size()]);
- return abpEngine.matches(url, contentType, referrerChainArray);
+ return abpEngine.matches(fullUrl, contentType, referrerChainArray);
}
private List<String> buildReferrerChain(String url)
@@ -418,7 +421,7 @@
final int maxChainLength = 10;
for (int i = 0; i < maxChainLength && url != null; i++)
{
- referrerChain.add(url);
+ referrerChain.add(0, url);
url = referrerMapping.get(url);
}
return referrerChain;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld