| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2010 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2010 Apple Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 static bool isSeparator(UChar c) | 65 static bool isSeparator(UChar c) |
| 66 { | 66 { |
| 67 return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '=' || c == '
,' || c == '\0'; | 67 return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '=' || c == '
,' || c == '\0'; |
| 68 } | 68 } |
| 69 | 69 |
| 70 void HTMLMetaElement::parseContentAttribute(const String& content, KeyValuePairC
allback callback, void* data) | 70 void HTMLMetaElement::parseContentAttribute(const String& content, KeyValuePairC
allback callback, void* data) |
| 71 { | 71 { |
| 72 bool error = false; | 72 bool error = false; |
| 73 | 73 |
| 74 // Tread lightly in this code -- it was specifically designed to mimic Win I
E's parsing behavior. | 74 // Tread lightly in this code -- it was specifically designed to mimic Win I
E's parsing behavior. |
| 75 int keyBegin, keyEnd; | 75 unsigned keyBegin, keyEnd; |
| 76 int valueBegin, valueEnd; | 76 unsigned valueBegin, valueEnd; |
| 77 | 77 |
| 78 int i = 0; | |
| 79 int length = content.length(); | |
| 80 String buffer = content.lower(); | 78 String buffer = content.lower(); |
| 81 while (i < length) { | 79 unsigned length = buffer.length(); |
| 80 for (unsigned i = 0; i < length; /* no increment here */) { |
| 82 // skip to first non-separator, but don't skip past the end of the strin
g | 81 // skip to first non-separator, but don't skip past the end of the strin
g |
| 83 while (isSeparator(buffer[i])) { | 82 while (isSeparator(buffer[i])) { |
| 84 if (i >= length) | 83 if (i >= length) |
| 85 break; | 84 break; |
| 86 i++; | 85 i++; |
| 87 } | 86 } |
| 88 keyBegin = i; | 87 keyBegin = i; |
| 89 | 88 |
| 90 // skip to first separator | 89 // skip to first separator |
| 91 while (!isSeparator(buffer[i])) { | 90 while (!isSeparator(buffer[i])) { |
| 92 error |= isInvalidSeparator(buffer[i]); | 91 error |= isInvalidSeparator(buffer[i]); |
| 92 if (i >= length) |
| 93 break; |
| 93 i++; | 94 i++; |
| 94 } | 95 } |
| 95 keyEnd = i; | 96 keyEnd = i; |
| 96 | 97 |
| 97 // skip to first '=', but don't skip past a ',' or the end of the string | 98 // skip to first '=', but don't skip past a ',' or the end of the string |
| 98 while (buffer[i] != '=') { | 99 while (buffer[i] != '=') { |
| 99 error |= isInvalidSeparator(buffer[i]); | 100 error |= isInvalidSeparator(buffer[i]); |
| 100 if (buffer[i] == ',' || i >= length) | 101 if (buffer[i] == ',' || i >= length) |
| 101 break; | 102 break; |
| 102 i++; | 103 i++; |
| 103 } | 104 } |
| 104 | 105 |
| 105 // skip to first non-separator, but don't skip past a ',' or the end of
the string | 106 // skip to first non-separator, but don't skip past a ',' or the end of
the string |
| 106 while (isSeparator(buffer[i])) { | 107 while (isSeparator(buffer[i])) { |
| 107 if (buffer[i] == ',' || i >= length) | 108 if (buffer[i] == ',' || i >= length) |
| 108 break; | 109 break; |
| 109 i++; | 110 i++; |
| 110 } | 111 } |
| 111 valueBegin = i; | 112 valueBegin = i; |
| 112 | 113 |
| 113 // skip to first separator | 114 // skip to first separator |
| 114 while (!isSeparator(buffer[i])) { | 115 while (!isSeparator(buffer[i])) { |
| 115 error |= isInvalidSeparator(buffer[i]); | 116 error |= isInvalidSeparator(buffer[i]); |
| 117 if (i >= length) |
| 118 break; |
| 116 i++; | 119 i++; |
| 117 } | 120 } |
| 118 valueEnd = i; | 121 valueEnd = i; |
| 119 | 122 |
| 120 ASSERT_WITH_SECURITY_IMPLICATION(i <= length); | 123 ASSERT_WITH_SECURITY_IMPLICATION(i <= length); |
| 121 | 124 |
| 122 String keyString = buffer.substring(keyBegin, keyEnd - keyBegin); | 125 String keyString = buffer.substring(keyBegin, keyEnd - keyBegin); |
| 123 String valueString = buffer.substring(valueBegin, valueEnd - valueBegin)
; | 126 String valueString = buffer.substring(valueBegin, valueEnd - valueBegin)
; |
| 124 (this->*callback)(keyString, valueString, data); | 127 (this->*callback)(keyString, valueString, data); |
| 125 } | 128 } |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 { | 496 { |
| 494 return getAttribute(http_equivAttr); | 497 return getAttribute(http_equivAttr); |
| 495 } | 498 } |
| 496 | 499 |
| 497 const AtomicString& HTMLMetaElement::name() const | 500 const AtomicString& HTMLMetaElement::name() const |
| 498 { | 501 { |
| 499 return getNameAttribute(); | 502 return getNameAttribute(); |
| 500 } | 503 } |
| 501 | 504 |
| 502 } | 505 } |
| OLD | NEW |