| OLD | NEW |
| 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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 startPosition = foundPosition + 2; | 749 startPosition = foundPosition + 2; |
| 750 else | 750 else |
| 751 startPosition = endPosition; | 751 startPosition = endPosition; |
| 752 } else | 752 } else |
| 753 break; | 753 break; |
| 754 } | 754 } |
| 755 | 755 |
| 756 String result; | 756 String result; |
| 757 while (startPosition < endPosition && !result.length()) { | 757 while (startPosition < endPosition && !result.length()) { |
| 758 // Stop at next comment (using the same rules as above for SVG/XML vs HT
ML), when we encounter a comma, | 758 // Stop at next comment (using the same rules as above for SVG/XML vs HT
ML), when we encounter a comma, |
| 759 // when we hit an opening <script> tag, or when we exceed the maximum le
ngth target. The comma rule | 759 // when we encoutner a backtick, when we hit an opening <script> tag, or
when we exceed the maximum length |
| 760 // covers a common parameter concatenation case performed by some web se
rvers. | 760 // target. The comma rule covers a common parameter concatenation case p
erformed by some web servers. The |
| 761 // backtick rule covers the ECMA6 multi-line template string feature. |
| 761 lastNonSpacePosition = kNotFound; | 762 lastNonSpacePosition = kNotFound; |
| 762 for (foundPosition = startPosition; foundPosition < endPosition; foundPo
sition++) { | 763 for (foundPosition = startPosition; foundPosition < endPosition; foundPo
sition++) { |
| 763 if (!request.shouldAllowCDATA) { | 764 if (!request.shouldAllowCDATA) { |
| 764 if (startsSingleLineCommentAt(string, foundPosition) | 765 if (startsSingleLineCommentAt(string, foundPosition) |
| 765 || startsMultiLineCommentAt(string, foundPosition) | 766 || startsMultiLineCommentAt(string, foundPosition) |
| 766 || startsHTMLCommentAt(string, foundPosition)) { | 767 || startsHTMLCommentAt(string, foundPosition)) { |
| 767 break; | 768 break; |
| 768 } | 769 } |
| 769 } | 770 } |
| 770 if (string[foundPosition] == ',') | 771 if (string[foundPosition] == ',' || string[foundPosition] == '`') |
| 771 break; | 772 break; |
| 772 | 773 |
| 773 if (lastNonSpacePosition != kNotFound && startsOpeningScriptTagAt(st
ring, foundPosition)) { | 774 if (lastNonSpacePosition != kNotFound && startsOpeningScriptTagAt(st
ring, foundPosition)) { |
| 774 foundPosition = lastNonSpacePosition; | 775 foundPosition = lastNonSpacePosition; |
| 775 break; | 776 break; |
| 776 } | 777 } |
| 777 if (foundPosition > startPosition + kMaximumFragmentLengthTarget) { | 778 if (foundPosition > startPosition + kMaximumFragmentLengthTarget) { |
| 778 // After hitting the length target, we can only stop at a point
where we know we are | 779 // After hitting the length target, we can only stop at a point
where we know we are |
| 779 // not in the middle of a %-escape sequence. For the sake of sim
plicity, approximate | 780 // not in the middle of a %-escape sequence. For the sake of sim
plicity, approximate |
| 780 // not stopping inside a (possibly multiply encoded) %-escape se
quence by breaking on | 781 // not stopping inside a (possibly multiply encoded) %-escape se
quence by breaking on |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 | 827 |
| 827 bool XSSAuditor::isSafeToSendToAnotherThread() const | 828 bool XSSAuditor::isSafeToSendToAnotherThread() const |
| 828 { | 829 { |
| 829 return m_documentURL.isSafeToSendToAnotherThread() | 830 return m_documentURL.isSafeToSendToAnotherThread() |
| 830 && m_decodedURL.isSafeToSendToAnotherThread() | 831 && m_decodedURL.isSafeToSendToAnotherThread() |
| 831 && m_decodedHTTPBody.isSafeToSendToAnotherThread() | 832 && m_decodedHTTPBody.isSafeToSendToAnotherThread() |
| 832 && m_httpBodyAsString.isSafeToSendToAnotherThread(); | 833 && m_httpBodyAsString.isSafeToSendToAnotherThread(); |
| 833 } | 834 } |
| 834 | 835 |
| 835 } // namespace blink | 836 } // namespace blink |
| OLD | NEW |