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

Side by Side Diff: Source/core/loader/DocumentLoader.cpp

Issue 161383002: Disabling JavaScript in MHTML and limiting MHTML loading to top frames. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Last upload seemed confused Created 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 frameLoader()->checkLoadComplete(); 272 frameLoader()->checkLoadComplete();
273 273
274 // If the document specified an application cache manifest, it violates the author's intent if we store it in the memory cache 274 // If the document specified an application cache manifest, it violates the author's intent if we store it in the memory cache
275 // and deny the appcache the chance to intercept it in the future, so remove from the memory cache. 275 // and deny the appcache the chance to intercept it in the future, so remove from the memory cache.
276 if (m_frame) { 276 if (m_frame) {
277 if (m_mainResource && m_frame->document()->hasManifest()) 277 if (m_mainResource && m_frame->document()->hasManifest())
278 memoryCache()->remove(m_mainResource.get()); 278 memoryCache()->remove(m_mainResource.get());
279 } 279 }
280 m_applicationCacheHost->finishedLoadingMainResource(); 280 m_applicationCacheHost->finishedLoadingMainResource();
281 clearMainResourceHandle(); 281 clearMainResourceHandle();
282
283 if (m_archive && document())
284 document()->enforceSandboxFlags(SandboxAll);
abarth-chromium 2014/02/12 23:35:39 This is probably too late. You want to enforce th
282 } 285 }
283 286
284 bool DocumentLoader::isRedirectAfterPost(const ResourceRequest& newRequest, cons t ResourceResponse& redirectResponse) 287 bool DocumentLoader::isRedirectAfterPost(const ResourceRequest& newRequest, cons t ResourceResponse& redirectResponse)
285 { 288 {
286 int status = redirectResponse.httpStatusCode(); 289 int status = redirectResponse.httpStatusCode();
287 if (((status >= 301 && status <= 303) || status == 307) 290 if (((status >= 301 && status <= 303) || status == 307)
288 && m_originalRequest.httpMethod() == "POST") 291 && m_originalRequest.httpMethod() == "POST")
289 return true; 292 return true;
290 293
291 return false; 294 return false;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 if (doc->processingLoadEvent()) 604 if (doc->processingLoadEvent())
602 return true; 605 return true;
603 if (doc->hasActiveParser()) 606 if (doc->hasActiveParser())
604 return true; 607 return true;
605 } 608 }
606 return frameLoader()->subframeIsLoading(); 609 return frameLoader()->subframeIsLoading();
607 } 610 }
608 611
609 bool DocumentLoader::maybeCreateArchive() 612 bool DocumentLoader::maybeCreateArchive()
610 { 613 {
614 // Only the top-frame can load MHTML.
615 if (m_frame->tree().parent())
616 return false;
617
611 // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0. 618 // Give the archive machinery a crack at this document. If the MIME type is not an archive type, it will return 0.
612 if (!isArchiveMIMEType(m_response.mimeType())) 619 if (!isArchiveMIMEType(m_response.mimeType()))
613 return false; 620 return false;
614 621
615 ASSERT(m_mainResource); 622 ASSERT(m_mainResource);
616 m_archive = MHTMLArchive::create(m_response.url(), m_mainResource->resourceB uffer()); 623 m_archive = MHTMLArchive::create(m_response.url(), m_mainResource->resourceB uffer());
617 // Invalid MHTML. 624 // Invalid MHTML.
618 if (!m_archive || !m_archive->mainResource()) { 625 if (!m_archive || !m_archive->mainResource()) {
619 m_archive.clear(); 626 m_archive.clear();
620 return false; 627 return false;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 void DocumentLoader::replaceDocument(const String& source, Document* ownerDocume nt) 852 void DocumentLoader::replaceDocument(const String& source, Document* ownerDocume nt)
846 { 853 {
847 m_frame->loader().stopAllLoaders(); 854 m_frame->loader().stopAllLoaders();
848 m_writer = createWriterFor(m_frame, ownerDocument, m_frame->document()->url( ), mimeType(), m_writer ? m_writer->encoding() : emptyAtom, m_writer ? m_writer ->encodingWasChosenByUser() : false, true); 855 m_writer = createWriterFor(m_frame, ownerDocument, m_frame->document()->url( ), mimeType(), m_writer ? m_writer->encoding() : emptyAtom, m_writer ? m_writer ->encodingWasChosenByUser() : false, true);
849 if (!source.isNull()) 856 if (!source.isNull())
850 m_writer->appendReplacingData(source); 857 m_writer->appendReplacingData(source);
851 endWriting(m_writer.get()); 858 endWriting(m_writer.get());
852 } 859 }
853 860
854 } // namespace WebCore 861 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/platform/win/mhtml/invalid-bad-boundary2-expected.png ('k') | Source/web/tests/MHTMLTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698