OLD | NEW |
---|---|
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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed. |
6 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 6 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 } | 315 } |
316 | 316 |
317 bool isSVGScriptLoader(Element* element) | 317 bool isSVGScriptLoader(Element* element) |
318 { | 318 { |
319 ASSERT(element); | 319 ASSERT(element); |
320 return isSVGScriptElement(*element); | 320 return isSVGScriptElement(*element); |
321 } | 321 } |
322 | 322 |
323 bool ScriptLoader::executeScript(const ScriptSourceCode& sourceCode, double* com pilationFinishTime) | 323 bool ScriptLoader::executeScript(const ScriptSourceCode& sourceCode, double* com pilationFinishTime) |
324 { | 324 { |
325 fprintf(stderr, "ScriptLoader::executeScript\n"); | |
rmcilroy
2015/04/17 12:59:32
leftover debugging?
alex clarke (OOO till 29th)
2015/04/17 13:37:08
Done.
| |
325 ASSERT(m_alreadyStarted); | 326 ASSERT(m_alreadyStarted); |
326 | 327 |
327 if (sourceCode.isEmpty()) | 328 if (sourceCode.isEmpty()) |
328 return true; | 329 return true; |
329 | 330 |
330 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); | 331 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); |
331 RefPtrWillBeRawPtr<Document> contextDocument = elementDocument->contextDocum ent().get(); | 332 RefPtrWillBeRawPtr<Document> contextDocument = elementDocument->contextDocum ent().get(); |
332 if (!contextDocument) | 333 if (!contextDocument) |
333 return true; | 334 return true; |
334 | 335 |
335 LocalFrame* frame = contextDocument->frame(); | 336 LocalFrame* frame = contextDocument->frame(); |
336 | 337 |
337 const ContentSecurityPolicy* csp = elementDocument->contentSecurityPolicy(); | 338 const ContentSecurityPolicy* csp = elementDocument->contentSecurityPolicy(); |
338 bool shouldBypassMainWorldCSP = (frame && frame->script().shouldBypassMainWo rldCSP()) | 339 bool shouldBypassMainWorldCSP = (frame && frame->script().shouldBypassMainWo rldCSP()) |
339 || csp->allowScriptWithNonce(m_element->fastGetAttribute(HTMLNames::nonc eAttr)) | 340 || csp->allowScriptWithNonce(m_element->fastGetAttribute(HTMLNames::nonc eAttr)) |
340 || csp->allowScriptWithHash(sourceCode.source()); | 341 || csp->allowScriptWithHash(sourceCode.source()); |
341 | 342 |
342 if (!m_isExternalScript && (!shouldBypassMainWorldCSP && !csp->allowInlineSc ript(elementDocument->url(), m_startLineNumber, sourceCode.source()))) { | 343 if (!m_isExternalScript && (!shouldBypassMainWorldCSP && !csp->allowInlineSc ript(elementDocument->url(), m_startLineNumber, sourceCode.source()))) { |
343 return false; | 344 return false; |
344 } | 345 } |
345 | 346 |
346 if (m_isExternalScript) { | 347 if (m_isExternalScript) { |
347 ScriptResource* resource = m_resource ? m_resource.get() : sourceCode.re source(); | 348 ScriptResource* resource = m_resource ? m_resource.get() : sourceCode.re source(); |
349 | |
348 if (resource && !resource->mimeTypeAllowedByNosniff()) { | 350 if (resource && !resource->mimeTypeAllowedByNosniff()) { |
349 contextDocument->addConsoleMessage(ConsoleMessage::create(SecurityMe ssageSource, ErrorMessageLevel, "Refused to execute script from '" + resource->u rl().elidedString() + "' because its MIME type ('" + resource->mimeType() + "') is not executable, and strict MIME type checking is enabled.")); | 351 contextDocument->addConsoleMessage(ConsoleMessage::create(SecurityMe ssageSource, ErrorMessageLevel, "Refused to execute script from '" + resource->u rl().elidedString() + "' because its MIME type ('" + resource->mimeType() + "') is not executable, and strict MIME type checking is enabled.")); |
350 return false; | 352 return false; |
351 } | 353 } |
352 | 354 |
353 if (resource && resource->mimeType().lower().startsWith("image/")) { | 355 if (resource && resource->mimeType().lower().startsWith("image/")) { |
354 contextDocument->addConsoleMessage(ConsoleMessage::create(SecurityMe ssageSource, ErrorMessageLevel, "Refused to execute script from '" + resource->u rl().elidedString() + "' because its MIME type ('" + resource->mimeType() + "') is not executable.")); | 356 contextDocument->addConsoleMessage(ConsoleMessage::create(SecurityMe ssageSource, ErrorMessageLevel, "Refused to execute script from '" + resource->u rl().elidedString() + "' because its MIME type ('" + resource->mimeType() + "') is not executable.")); |
355 UseCounter::count(frame, UseCounter::BlockedSniffingImageToScript); | 357 UseCounter::count(frame, UseCounter::BlockedSniffingImageToScript); |
356 return false; | 358 return false; |
357 } | 359 } |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 if (isHTMLScriptLoader(element)) | 488 if (isHTMLScriptLoader(element)) |
487 return toHTMLScriptElement(element)->loader(); | 489 return toHTMLScriptElement(element)->loader(); |
488 | 490 |
489 if (isSVGScriptLoader(element)) | 491 if (isSVGScriptLoader(element)) |
490 return toSVGScriptElement(element)->loader(); | 492 return toSVGScriptElement(element)->loader(); |
491 | 493 |
492 return 0; | 494 return 0; |
493 } | 495 } |
494 | 496 |
495 } // namespace blink | 497 } // namespace blink |
OLD | NEW |