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

Side by Side Diff: Source/core/html/parser/XSSAuditor.cpp

Issue 346623003: Reverse order of tests in eraseDangerousAttributeIfInjected(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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
« no previous file with comments | « LayoutTests/http/tests/security/xssAuditor/svg-animate-clutter-2-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Adam Barth. All Rights Reserved. 2 * Copyright (C) 2011 Adam Barth. All Rights Reserved.
3 * Copyright (C) 2011 Daniel Bates (dbates@intudata.com). 3 * Copyright (C) 2011 Daniel Bates (dbates@intudata.com).
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 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 DEFINE_STATIC_LOCAL(String, safeJavaScriptURL, ("javascript:void(0)")); 600 DEFINE_STATIC_LOCAL(String, safeJavaScriptURL, ("javascript:void(0)"));
601 601
602 bool didBlockScript = false; 602 bool didBlockScript = false;
603 for (size_t i = 0; i < request.token.attributes().size(); ++i) { 603 for (size_t i = 0; i < request.token.attributes().size(); ++i) {
604 bool eraseAttribute = false; 604 bool eraseAttribute = false;
605 bool valueContainsJavaScriptURL = false; 605 bool valueContainsJavaScriptURL = false;
606 const HTMLToken::Attribute& attribute = request.token.attributes().at(i) ; 606 const HTMLToken::Attribute& attribute = request.token.attributes().at(i) ;
607 // FIXME: Don't create a new String for every attribute.value in the doc ument. 607 // FIXME: Don't create a new String for every attribute.value in the doc ument.
608 if (isNameOfInlineEventHandler(attribute.name)) { 608 if (isNameOfInlineEventHandler(attribute.name)) {
609 eraseAttribute = isContainedInRequest(canonicalize(snippetFromAttrib ute(request, attribute), ScriptLikeAttributeTruncation)); 609 eraseAttribute = isContainedInRequest(canonicalize(snippetFromAttrib ute(request, attribute), ScriptLikeAttributeTruncation));
610 } else if (protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(String (attribute.value)))) {
611 valueContainsJavaScriptURL = true;
612 eraseAttribute = isContainedInRequest(canonicalize(snippetFromAttrib ute(request, attribute), ScriptLikeAttributeTruncation));
613 } else if (isSemicolonSeparatedAttribute(attribute)) { 610 } else if (isSemicolonSeparatedAttribute(attribute)) {
614 String subValue = semicolonSeparatedValueContainingJavaScriptURL(Str ing(attribute.value)); 611 String subValue = semicolonSeparatedValueContainingJavaScriptURL(Str ing(attribute.value));
615 if (!subValue.isEmpty()) { 612 if (!subValue.isEmpty()) {
616 valueContainsJavaScriptURL = true; 613 valueContainsJavaScriptURL = true;
617 eraseAttribute = isContainedInRequest(canonicalize(nameFromAttri bute(request, attribute), NoTruncation)) 614 eraseAttribute = isContainedInRequest(canonicalize(nameFromAttri bute(request, attribute), NoTruncation))
618 && isContainedInRequest(canonicalize(subValue, ScriptLikeAtt ributeTruncation)); 615 && isContainedInRequest(canonicalize(subValue, ScriptLikeAtt ributeTruncation));
619 } 616 }
617 } else if (protocolIsJavaScript(stripLeadingAndTrailingHTMLSpaces(String (attribute.value)))) {
618 valueContainsJavaScriptURL = true;
619 eraseAttribute = isContainedInRequest(canonicalize(snippetFromAttrib ute(request, attribute), ScriptLikeAttributeTruncation));
620 } 620 }
621 if (!eraseAttribute) 621 if (!eraseAttribute)
622 continue; 622 continue;
623 request.token.eraseValueOfAttribute(i); 623 request.token.eraseValueOfAttribute(i);
624 if (valueContainsJavaScriptURL) 624 if (valueContainsJavaScriptURL)
625 request.token.appendToAttributeValue(i, safeJavaScriptURL); 625 request.token.appendToAttributeValue(i, safeJavaScriptURL);
626 didBlockScript = true; 626 didBlockScript = true;
627 } 627 }
628 return didBlockScript; 628 return didBlockScript;
629 } 629 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 800
801 bool XSSAuditor::isSafeToSendToAnotherThread() const 801 bool XSSAuditor::isSafeToSendToAnotherThread() const
802 { 802 {
803 return m_documentURL.isSafeToSendToAnotherThread() 803 return m_documentURL.isSafeToSendToAnotherThread()
804 && m_decodedURL.isSafeToSendToAnotherThread() 804 && m_decodedURL.isSafeToSendToAnotherThread()
805 && m_decodedHTTPBody.isSafeToSendToAnotherThread() 805 && m_decodedHTTPBody.isSafeToSendToAnotherThread()
806 && m_httpBodyAsString.isSafeToSendToAnotherThread(); 806 && m_httpBodyAsString.isSafeToSendToAnotherThread();
807 } 807 }
808 808
809 } // namespace WebCore 809 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/security/xssAuditor/svg-animate-clutter-2-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698