| 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 } | 464 } |
| 465 } | 465 } |
| 466 | 466 |
| 467 bool XSSAuditor::filterCharacterToken(const FilterTokenRequest& request) | 467 bool XSSAuditor::filterCharacterToken(const FilterTokenRequest& request) |
| 468 { | 468 { |
| 469 ASSERT(m_scriptTagNestingLevel); | 469 ASSERT(m_scriptTagNestingLevel); |
| 470 ASSERT(m_state != Uninitialized); | 470 ASSERT(m_state != Uninitialized); |
| 471 if (m_state == PermittingAdjacentCharacterTokens) | 471 if (m_state == PermittingAdjacentCharacterTokens) |
| 472 return false; | 472 return false; |
| 473 | 473 |
| 474 if ((m_state == SuppressingAdjacentCharacterTokens) | 474 if (m_state == FilteringTokens && m_scriptTagFoundInRequest) { |
| 475 || (m_scriptTagFoundInRequest && isContainedInRequest(canonicalizedSnipp
etForJavaScript(request)))) { | 475 String snippet = canonicalizedSnippetForJavaScript(request); |
| 476 if (isContainedInRequest(snippet)) |
| 477 m_state = SuppressingAdjacentCharacterTokens; |
| 478 else if (!snippet.isEmpty()) |
| 479 m_state = PermittingAdjacentCharacterTokens; |
| 480 } |
| 481 if (m_state == SuppressingAdjacentCharacterTokens) { |
| 476 request.token.eraseCharacters(); | 482 request.token.eraseCharacters(); |
| 477 request.token.appendToCharacter(' '); // Technically, character tokens c
an't be empty. | 483 request.token.appendToCharacter(' '); // Technically, character tokens c
an't be empty. |
| 478 m_state = SuppressingAdjacentCharacterTokens; | |
| 479 return true; | 484 return true; |
| 480 } | 485 } |
| 481 | |
| 482 m_state = PermittingAdjacentCharacterTokens; | |
| 483 return false; | 486 return false; |
| 484 } | 487 } |
| 485 | 488 |
| 486 bool XSSAuditor::filterScriptToken(const FilterTokenRequest& request) | 489 bool XSSAuditor::filterScriptToken(const FilterTokenRequest& request) |
| 487 { | 490 { |
| 488 ASSERT(request.token.type() == HTMLToken::StartTag); | 491 ASSERT(request.token.type() == HTMLToken::StartTag); |
| 489 ASSERT(hasName(request.token, scriptTag)); | 492 ASSERT(hasName(request.token, scriptTag)); |
| 490 | 493 |
| 491 bool didBlockScript = false; | 494 bool didBlockScript = false; |
| 492 m_scriptTagFoundInRequest = isContainedInRequest(canonicalizedSnippetForTagN
ame(request)); | 495 m_scriptTagFoundInRequest = isContainedInRequest(canonicalizedSnippetForTagN
ame(request)); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 | 837 |
| 835 bool XSSAuditor::isSafeToSendToAnotherThread() const | 838 bool XSSAuditor::isSafeToSendToAnotherThread() const |
| 836 { | 839 { |
| 837 return m_documentURL.isSafeToSendToAnotherThread() | 840 return m_documentURL.isSafeToSendToAnotherThread() |
| 838 && m_decodedURL.isSafeToSendToAnotherThread() | 841 && m_decodedURL.isSafeToSendToAnotherThread() |
| 839 && m_decodedHTTPBody.isSafeToSendToAnotherThread() | 842 && m_decodedHTTPBody.isSafeToSendToAnotherThread() |
| 840 && m_httpBodyAsString.isSafeToSendToAnotherThread(); | 843 && m_httpBodyAsString.isSafeToSendToAnotherThread(); |
| 841 } | 844 } |
| 842 | 845 |
| 843 } // namespace blink | 846 } // namespace blink |
| OLD | NEW |