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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 using namespace HTMLNames; | 58 using namespace HTMLNames; |
59 | 59 |
60 static bool isNonCanonicalCharacter(UChar c) | 60 static bool isNonCanonicalCharacter(UChar c) |
61 { | 61 { |
62 // We remove all non-ASCII characters, including non-printable ASCII charact
ers. | 62 // We remove all non-ASCII characters, including non-printable ASCII charact
ers. |
63 // | 63 // |
64 // Note, we don't remove backslashes like PHP stripslashes(), which among ot
her things converts "\\0" to the \0 character. | 64 // Note, we don't remove backslashes like PHP stripslashes(), which among ot
her things converts "\\0" to the \0 character. |
65 // Instead, we remove backslashes and zeros (since the string "\\0" =(remove
backslashes)=> "0"). However, this has the | 65 // Instead, we remove backslashes and zeros (since the string "\\0" =(remove
backslashes)=> "0"). However, this has the |
66 // adverse effect that we remove any legitimate zeros from a string. | 66 // adverse effect that we remove any legitimate zeros from a string. |
| 67 // |
67 // We also remove forward-slash, because it is common for some servers to co
llapse successive path components, eg, | 68 // We also remove forward-slash, because it is common for some servers to co
llapse successive path components, eg, |
68 // a//b becomes a/b. | 69 // a//b becomes a/b. |
69 // | 70 // |
70 // For instance: new String("http://localhost:8000") => new String("http:loc
alhost:8"). | 71 // We also remove the questionmark character, since some severs replace inva
lid high-bytes with a questionmark. We |
71 return (c == '\\' || c == '0' || c == '\0' || c == '/' || c >= 127); | 72 // are already stripping the high-bytes so we also strip the questionmark to
match. |
| 73 // |
| 74 // For instance: new String("http://localhost:8000?x") => new String("http:l
ocalhost:8x"). |
| 75 return (c == '\\' || c == '0' || c == '\0' || c == '/' || c == '?' || c >= 1
27); |
72 } | 76 } |
73 | 77 |
74 static bool isRequiredForInjection(UChar c) | 78 static bool isRequiredForInjection(UChar c) |
75 { | 79 { |
76 return (c == '\'' || c == '"' || c == '<' || c == '>'); | 80 return (c == '\'' || c == '"' || c == '<' || c == '>'); |
77 } | 81 } |
78 | 82 |
79 static bool isTerminatingCharacter(UChar c) | 83 static bool isTerminatingCharacter(UChar c) |
80 { | 84 { |
81 return (c == '&' || c == '/' || c == '"' || c == '\'' || c == '<' || c == '>
' || c == ','); | 85 return (c == '&' || c == '/' || c == '"' || c == '\'' || c == '<' || c == '>
' || c == ','); |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 | 804 |
801 bool XSSAuditor::isSafeToSendToAnotherThread() const | 805 bool XSSAuditor::isSafeToSendToAnotherThread() const |
802 { | 806 { |
803 return m_documentURL.isSafeToSendToAnotherThread() | 807 return m_documentURL.isSafeToSendToAnotherThread() |
804 && m_decodedURL.isSafeToSendToAnotherThread() | 808 && m_decodedURL.isSafeToSendToAnotherThread() |
805 && m_decodedHTTPBody.isSafeToSendToAnotherThread() | 809 && m_decodedHTTPBody.isSafeToSendToAnotherThread() |
806 && m_httpBodyAsString.isSafeToSendToAnotherThread(); | 810 && m_httpBodyAsString.isSafeToSendToAnotherThread(); |
807 } | 811 } |
808 | 812 |
809 } // namespace blink | 813 } // namespace blink |
OLD | NEW |