| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2007, 2008, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2007, 2008, 2011, 2012 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. | 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. |
| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 6000, // X11 | 122 6000, // X11 |
| 123 6665, // Alternate IRC [Apple addition] | 123 6665, // Alternate IRC [Apple addition] |
| 124 6666, // Alternate IRC [Apple addition] | 124 6666, // Alternate IRC [Apple addition] |
| 125 6667, // Standard IRC [Apple addition] | 125 6667, // Standard IRC [Apple addition] |
| 126 6668, // Alternate IRC [Apple addition] | 126 6668, // Alternate IRC [Apple addition] |
| 127 6669, // Alternate IRC [Apple addition] | 127 6669, // Alternate IRC [Apple addition] |
| 128 0xFFFF, // Used to block all invalid port numbers | 128 0xFFFF, // Used to block all invalid port numbers |
| 129 }; | 129 }; |
| 130 const unsigned short* const blockedPortListEnd = blockedPortList + WTF_ARRAY
_LENGTH(blockedPortList); | 130 const unsigned short* const blockedPortListEnd = blockedPortList + WTF_ARRAY
_LENGTH(blockedPortList); |
| 131 | 131 |
| 132 #ifndef NDEBUG | 132 #if ENABLE(ASSERT) |
| 133 // The port list must be sorted for binary_search to work. | 133 // The port list must be sorted for binary_search to work. |
| 134 static bool checkedPortList = false; | 134 static bool checkedPortList = false; |
| 135 if (!checkedPortList) { | 135 if (!checkedPortList) { |
| 136 for (const unsigned short* p = blockedPortList; p != blockedPortListEnd
- 1; ++p) | 136 for (const unsigned short* p = blockedPortList; p != blockedPortListEnd
- 1; ++p) |
| 137 ASSERT(*p < *(p + 1)); | 137 ASSERT(*p < *(p + 1)); |
| 138 checkedPortList = true; | 138 checkedPortList = true; |
| 139 } | 139 } |
| 140 #endif | 140 #endif |
| 141 | 141 |
| 142 // If the port is not in the blocked port list, allow it. | 142 // If the port is not in the blocked port list, allow it. |
| 143 if (!std::binary_search(blockedPortList, blockedPortListEnd, port)) | 143 if (!std::binary_search(blockedPortList, blockedPortListEnd, port)) |
| 144 return true; | 144 return true; |
| 145 | 145 |
| 146 // Allow ports 21 and 22 for FTP URLs, as Mozilla does. | 146 // Allow ports 21 and 22 for FTP URLs, as Mozilla does. |
| 147 if ((port == 21 || port == 22) && url.protocolIs("ftp")) | 147 if ((port == 21 || port == 22) && url.protocolIs("ftp")) |
| 148 return true; | 148 return true; |
| 149 | 149 |
| 150 // Allow any port number in a file URL, since the port number is ignored. | 150 // Allow any port number in a file URL, since the port number is ignored. |
| 151 if (url.protocolIs("file")) | 151 if (url.protocolIs("file")) |
| 152 return true; | 152 return true; |
| 153 | 153 |
| 154 return false; | 154 return false; |
| 155 } | 155 } |
| 156 | 156 |
| 157 } | 157 } |
| OLD | NEW |