Chromium Code Reviews| Index: Source/core/inspector/InspectorResourceAgent.cpp |
| diff --git a/Source/core/inspector/InspectorResourceAgent.cpp b/Source/core/inspector/InspectorResourceAgent.cpp |
| index 8aec85c9d0b3695925377e18911f1eced012a139..d72695899a3d611deab949242d2e00862949654c 100644 |
| --- a/Source/core/inspector/InspectorResourceAgent.cpp |
| +++ b/Source/core/inspector/InspectorResourceAgent.cpp |
| @@ -95,6 +95,27 @@ namespace { |
| // Keep in sync with kDevToolsRequestInitiator defined in devtools_network_controller.cc |
| const char kDevToolsEmulateNetworkConditionsClientId[] = "X-DevTools-Emulate-Network-Conditions-Client-Id"; |
| +// Pattern may contain stars ('*') which match to any (possibly empty) string. |
| +// Stars implicitly assumed at the begin/end of pattern. |
| +bool matches(const String& url, const String& pattern) |
| +{ |
| + size_t done = 0; |
| + size_t pos = 0; |
|
caseq
2015/09/08 23:02:14
move down to actual usage?
|
| + while (done < pattern.length()) { |
| + size_t index = pattern.find('*', done); |
| + if (index == kNotFound) |
| + index = pattern.length(); |
| + if (index > done) { |
| + pos = url.find(pattern.substring(done, index - done)); |
|
caseq
2015/09/08 23:02:14
So a*b*c would match "bac", right?
|
| + if (pos == kNotFound) |
| + return false; |
| + pos = pos + index - done; |
|
caseq
2015/09/08 23:02:14
what is the effect of this?
|
| + } |
| + done = index + 1; |
| + } |
| + return true; |
| +} |
| + |
| static PassRefPtr<JSONObject> buildObjectForHeaders(const HTTPHeaderMap& headers) |
| { |
| RefPtr<JSONObject> headersObject = JSONObject::create(); |
| @@ -407,7 +428,7 @@ bool InspectorResourceAgent::shouldBlockRequest(const ResourceRequest& request) |
| String url = request.url().string(); |
| RefPtr<JSONObject> blockedURLs = m_state->getObject(ResourceAgentState::blockedURLs); |
| for (const auto& entry : *blockedURLs) { |
| - if (url.contains(entry.key)) |
| + if (matches(url, entry.key)) |
| return true; |
| } |
| return false; |