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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2685843003: 'data:' may not be used as a document's base URL. (Closed)
Patch Set: Tests. Created 3 years, 10 months 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 3307 matching lines...) Expand 10 before | Expand all | Expand 10 after
3318 // FIXME: Since this doesn't share code with completeURL it may not handle 3318 // FIXME: Since this doesn't share code with completeURL it may not handle
3319 // encodings correctly. 3319 // encodings correctly.
3320 KURL baseElementURL; 3320 KURL baseElementURL;
3321 if (href) { 3321 if (href) {
3322 String strippedHref = stripLeadingAndTrailingHTMLSpaces(*href); 3322 String strippedHref = stripLeadingAndTrailingHTMLSpaces(*href);
3323 if (!strippedHref.isEmpty()) 3323 if (!strippedHref.isEmpty())
3324 baseElementURL = KURL(url(), strippedHref); 3324 baseElementURL = KURL(url(), strippedHref);
3325 } 3325 }
3326 3326
3327 if (!baseElementURL.isEmpty()) { 3327 if (!baseElementURL.isEmpty()) {
3328 if (baseElementURL.protocolIsData()) 3328 if (baseElementURL.protocolIsData()) {
3329 UseCounter::count(*this, UseCounter::BaseWithDataHref); 3329 UseCounter::count(*this, UseCounter::BaseWithDataHref);
3330 addConsoleMessage(ConsoleMessage::create(
3331 SecurityMessageSource, ErrorMessageLevel,
3332 "'data:' URLs may not be used as base URLs for a document."));
3333 }
3330 if (!this->getSecurityOrigin()->canRequest(baseElementURL)) 3334 if (!this->getSecurityOrigin()->canRequest(baseElementURL))
3331 UseCounter::count(*this, UseCounter::BaseWithCrossOriginHref); 3335 UseCounter::count(*this, UseCounter::BaseWithCrossOriginHref);
3332 } 3336 }
3333 3337
3334 if (m_baseElementURL != baseElementURL && 3338 if (baseElementURL != m_baseElementURL && !baseElementURL.protocolIsData() &&
3335 contentSecurityPolicy()->allowBaseURI(baseElementURL)) { 3339 contentSecurityPolicy()->allowBaseURI(baseElementURL)) {
3336 m_baseElementURL = baseElementURL; 3340 m_baseElementURL = baseElementURL;
3337 updateBaseURL(); 3341 updateBaseURL();
3338 } 3342 }
3339 3343
3340 if (target) { 3344 if (target) {
3341 if (target->contains('\n') || target->contains('\r')) 3345 if (target->contains('\n') || target->contains('\r'))
3342 UseCounter::count(*this, UseCounter::BaseWithNewlinesInTarget); 3346 UseCounter::count(*this, UseCounter::BaseWithNewlinesInTarget);
3343 if (target->contains('<')) 3347 if (target->contains('<'))
3344 UseCounter::count(*this, UseCounter::BaseWithOpenBracketInTarget); 3348 UseCounter::count(*this, UseCounter::BaseWithOpenBracketInTarget);
(...skipping 3231 matching lines...) Expand 10 before | Expand all | Expand 10 after
6576 } 6580 }
6577 6581
6578 void showLiveDocumentInstances() { 6582 void showLiveDocumentInstances() {
6579 WeakDocumentSet& set = liveDocumentSet(); 6583 WeakDocumentSet& set = liveDocumentSet();
6580 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6584 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6581 for (blink::Document* document : set) 6585 for (blink::Document* document : set)
6582 fprintf(stderr, "- Document %p URL: %s\n", document, 6586 fprintf(stderr, "- Document %p URL: %s\n", document,
6583 document->url().getString().utf8().data()); 6587 document->url().getString().utf8().data());
6584 } 6588 }
6585 #endif 6589 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698