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

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

Issue 210033008: Don't include trailing comments in javascript snippets. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 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/script-tag-with-injected-comment-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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 } 689 }
690 690
691 String result; 691 String result;
692 while (startPosition < endPosition && !result.length()) { 692 while (startPosition < endPosition && !result.length()) {
693 // Stop at next comment (using the same rules as above for SVG/XML vs HT ML), when we encounter a comma, 693 // Stop at next comment (using the same rules as above for SVG/XML vs HT ML), when we encounter a comma,
694 // when we hit an opening <script> tag, or when we exceed the maximum le ngth target. The comma rule 694 // when we hit an opening <script> tag, or when we exceed the maximum le ngth target. The comma rule
695 // covers a common parameter concatenation case performed by some web se rvers. 695 // covers a common parameter concatenation case performed by some web se rvers.
696 lastNonSpacePosition = kNotFound; 696 lastNonSpacePosition = kNotFound;
697 for (foundPosition = startPosition; foundPosition < endPosition; foundPo sition++) { 697 for (foundPosition = startPosition; foundPosition < endPosition; foundPo sition++) {
698 if (!request.shouldAllowCDATA) { 698 if (!request.shouldAllowCDATA) {
699 if (startsSingleLineCommentAt(string, foundPosition) || startsMu ltiLineCommentAt(string, foundPosition)) { 699 if (startsSingleLineCommentAt(string, foundPosition)
700 foundPosition += 2; 700 || startsMultiLineCommentAt(string, foundPosition)
701 break; 701 || startsHTMLCommentAt(string, foundPosition)) {
702 }
703 if (startsHTMLCommentAt(string, foundPosition)) {
704 foundPosition += 4;
705 break; 702 break;
706 } 703 }
707 } 704 }
708 if (string[foundPosition] == ',') 705 if (string[foundPosition] == ',')
709 break; 706 break;
710 707
711 if (lastNonSpacePosition != kNotFound && startsOpeningScriptTagAt(st ring, foundPosition)) { 708 if (lastNonSpacePosition != kNotFound && startsOpeningScriptTagAt(st ring, foundPosition)) {
712 foundPosition = lastNonSpacePosition; 709 foundPosition = lastNonSpacePosition;
713 break; 710 break;
714 } 711 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 763
767 bool XSSAuditor::isSafeToSendToAnotherThread() const 764 bool XSSAuditor::isSafeToSendToAnotherThread() const
768 { 765 {
769 return m_documentURL.isSafeToSendToAnotherThread() 766 return m_documentURL.isSafeToSendToAnotherThread()
770 && m_decodedURL.isSafeToSendToAnotherThread() 767 && m_decodedURL.isSafeToSendToAnotherThread()
771 && m_decodedHTTPBody.isSafeToSendToAnotherThread() 768 && m_decodedHTTPBody.isSafeToSendToAnotherThread()
772 && m_httpBodyAsString.isSafeToSendToAnotherThread(); 769 && m_httpBodyAsString.isSafeToSendToAnotherThread();
773 } 770 }
774 771
775 } // namespace WebCore 772 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/security/xssAuditor/script-tag-with-injected-comment-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698