Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Unified Diff: third_party/WebKit/Source/core/frame/csp/CSPSource.cpp

Issue 2550093005: Embedding-CSP: Fixing path matching (Closed)
Patch Set: Adding CSPSourceTest Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/csp/CSPSource.cpp
diff --git a/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp b/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp
index 81f66964e4db03816d773a155880f1434aa993bd..048ffcf414678e30ab747058100aef57f3019ed6 100644
--- a/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp
@@ -74,7 +74,7 @@ bool CSPSource::hostMatches(const String& host) const {
}
bool CSPSource::pathMatches(const String& urlPath) const {
- if (m_path.isEmpty())
+ if (m_path.isEmpty() || (m_path == "/" && urlPath.isEmpty()))
return true;
String path = decodeURLEscapeSequences(urlPath);
@@ -154,7 +154,9 @@ CSPSource* CSPSource::intersect(CSPSource* other) const {
}
String host = m_hostWildcard == NoWildcard ? m_host : other->m_host;
- String path = other->pathMatches(m_path) ? m_path : other->m_path;
+ // Since sources are similar and paths match, pick the longer one.
+ String path =
+ m_path.length() > other->m_path.length() ? m_path : other->m_path;
amalika 2016/12/08 19:30:59 Simplified the logic instead of adding another che
// Choose this port if the other port is empty, has wildcard or is a port for
// a less secure scheme such as "http" whereas scheme of this is "https", in
// which case the lengths would differ.

Powered by Google App Engine
This is Rietveld 408576698