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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLFrameElementBase.cpp

Issue 2183423002: Only do security checks on javascript: URLs for frames for loading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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) 2000 Simon Hausmann (hausmann@kde.org) 4 * (C) 2000 Simon Hausmann (hausmann@kde.org)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * Copyright (C) 2004, 2006, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2006, 2008, 2009 Apple Inc. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 using namespace HTMLNames; 43 using namespace HTMLNames;
44 44
45 HTMLFrameElementBase::HTMLFrameElementBase(const QualifiedName& tagName, Documen t& document) 45 HTMLFrameElementBase::HTMLFrameElementBase(const QualifiedName& tagName, Documen t& document)
46 : HTMLFrameOwnerElement(tagName, document) 46 : HTMLFrameOwnerElement(tagName, document)
47 , m_scrollingMode(ScrollbarAuto) 47 , m_scrollingMode(ScrollbarAuto)
48 , m_marginWidth(-1) 48 , m_marginWidth(-1)
49 , m_marginHeight(-1) 49 , m_marginHeight(-1)
50 { 50 {
51 } 51 }
52 52
53 bool HTMLFrameElementBase::isURLAllowed() const 53 bool HTMLFrameElementBase::isURLAllowed(ReasonForCallingURLAllowed reason) const
54 { 54 {
55 if (m_URL.isEmpty()) 55 if (m_URL.isEmpty())
56 return true; 56 return true;
57 57
58 const KURL& completeURL = document().completeURL(m_URL); 58 const KURL& completeURL = document().completeURL(m_URL);
59 59
60 if (protocolIsJavaScript(completeURL)) { 60 if (reason == WillLoadURL && protocolIsJavaScript(completeURL)) {
dcheng 2016/07/27 15:15:58 I wonder if we should just cache the result of thi
jochen (gone - plz use gerrit) 2016/07/27 15:19:37 well, if you want to do layout and get it wrong, y
dcheng 2016/07/27 15:39:06 I'm kind of thinking we should just reset this to
61 if (contentFrame() && !ScriptController::canAccessFromCurrentOrigin(toIs olate(&document()), contentFrame())) 61 if (contentFrame()) {
62 return false; 62 v8::Isolate* isolate = toIsolate(&document());
63 SECURITY_CHECK(isolate->InContext());
64 if (!ScriptController::canAccessFromCurrentOrigin(toIsolate(&documen t()), contentFrame()))
dcheng 2016/07/27 15:15:58 I wonder if we should remove the isolate->InContex
jochen (gone - plz use gerrit) 2016/07/27 15:19:37 done
65 return false;
66 }
63 } 67 }
64 68
65 LocalFrame* parentFrame = document().frame(); 69 LocalFrame* parentFrame = document().frame();
66 if (parentFrame) 70 if (parentFrame)
67 return parentFrame->isURLAllowed(completeURL); 71 return parentFrame->isURLAllowed(completeURL);
68 72
69 return true; 73 return true;
70 } 74 }
71 75
72 void HTMLFrameElementBase::openURL(bool replaceCurrentItem) 76 void HTMLFrameElementBase::openURL(bool replaceCurrentItem)
73 { 77 {
74 if (!isURLAllowed()) 78 if (!isURLAllowed(WillLoadURL))
75 return; 79 return;
76 80
77 if (m_URL.isEmpty()) 81 if (m_URL.isEmpty())
78 m_URL = AtomicString(blankURL().getString()); 82 m_URL = AtomicString(blankURL().getString());
79 83
80 LocalFrame* parentFrame = document().frame(); 84 LocalFrame* parentFrame = document().frame();
81 if (!parentFrame) 85 if (!parentFrame)
82 return; 86 return;
83 87
84 // Support for <frame src="javascript:string"> 88 // Support for <frame src="javascript:string">
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 frameOwnerPropertiesChanged(); 252 frameOwnerPropertiesChanged();
249 } 253 }
250 254
251 void HTMLFrameElementBase::setMarginHeight(int marginHeight) 255 void HTMLFrameElementBase::setMarginHeight(int marginHeight)
252 { 256 {
253 m_marginHeight = marginHeight; 257 m_marginHeight = marginHeight;
254 frameOwnerPropertiesChanged(); 258 frameOwnerPropertiesChanged();
255 } 259 }
256 260
257 } // namespace blink 261 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLFrameElementBase.h ('k') | third_party/WebKit/Source/core/html/HTMLIFrameElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698