OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r
ights reserved. |
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 9258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9269 return false; | 9269 return false; |
9270 } | 9270 } |
9271 } | 9271 } |
9272 | 9272 |
9273 return true; | 9273 return true; |
9274 } | 9274 } |
9275 | 9275 |
9276 // We use single quotes for now because markup.cpp uses double quotes. | 9276 // We use single quotes for now because markup.cpp uses double quotes. |
9277 String quoteCSSString(const String& string) | 9277 String quoteCSSString(const String& string) |
9278 { | 9278 { |
| 9279 // This function expands each character to at most 3 characters ('\u0010' ->
'\' '1' '0') as well as adds |
| 9280 // 2 quote characters (before and after). Make sure the resulting size (3 *
length + 2) will not overflow unsigned. |
| 9281 if (string.length() >= (std::numeric_limits<unsigned>::max() / 3) - 2) |
| 9282 return ""; |
| 9283 |
9279 // For efficiency, we first pre-calculate the length of the quoted string, t
hen we build the actual one. | 9284 // For efficiency, we first pre-calculate the length of the quoted string, t
hen we build the actual one. |
9280 // Please see below for the actual logic. | 9285 // Please see below for the actual logic. |
9281 unsigned quotedStringSize = 2; // Two quotes surrounding the entire string. | 9286 unsigned quotedStringSize = 2; // Two quotes surrounding the entire string. |
9282 bool afterEscape = false; | 9287 bool afterEscape = false; |
9283 for (unsigned i = 0; i < string.length(); ++i) { | 9288 for (unsigned i = 0; i < string.length(); ++i) { |
9284 UChar ch = string[i]; | 9289 UChar ch = string[i]; |
9285 if (ch == '\\' || ch == '\'') { | 9290 if (ch == '\\' || ch == '\'') { |
9286 quotedStringSize += 2; | 9291 quotedStringSize += 2; |
9287 afterEscape = false; | 9292 afterEscape = false; |
9288 } else if (ch < 0x20 || ch == 0x7F) { | 9293 } else if (ch < 0x20 || ch == 0x7F) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9336 { | 9341 { |
9337 // The tokenizer checks for the construct of an+b. | 9342 // The tokenizer checks for the construct of an+b. |
9338 // However, since the {ident} rule precedes the {nth} rule, some of those | 9343 // However, since the {ident} rule precedes the {nth} rule, some of those |
9339 // tokens are identified as string literal. Furthermore we need to accept | 9344 // tokens are identified as string literal. Furthermore we need to accept |
9340 // "odd" and "even" which does not match to an+b. | 9345 // "odd" and "even" which does not match to an+b. |
9341 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 9346 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
9342 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 9347 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
9343 } | 9348 } |
9344 | 9349 |
9345 } | 9350 } |
OLD | NEW |