• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3  * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB.  If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  */
21 
22 #include "config.h"
23 #include "CSSHelper.h"
24 
25 #include "PlatformString.h"
26 #include <wtf/Vector.h>
27 
28 namespace WebCore {
29 
deprecatedParseURL(const String & url)30 String deprecatedParseURL(const String& url)
31 {
32     StringImpl* i = url.impl();
33     if (!i)
34         return String();
35 
36     int o = 0;
37     int l = i->length();
38 
39     while (o < l && (*i)[o] <= ' ') {
40         ++o;
41         --l;
42     }
43     while (l > 0 && (*i)[o + l - 1] <= ' ')
44         --l;
45 
46     if (l >= 5
47             && ((*i)[o] == 'u' || (*i)[o] == 'U')
48             && ((*i)[o + 1] == 'r' || (*i)[o + 1] == 'R')
49             && ((*i)[o + 2] == 'l' || (*i)[o + 2] == 'L')
50             && (*i)[o + 3] == '('
51             && (*i)[o + l - 1] == ')') {
52         o += 4;
53         l -= 5;
54     }
55 
56     while (o < l && (*i)[o] <= ' ') {
57         ++o;
58         --l;
59     }
60     while (l > 0 && (*i)[o + l - 1] <= ' ')
61         --l;
62 
63     if (l >= 2 && (*i)[o] == (*i)[o + l - 1] && ((*i)[o] == '\'' || (*i)[o] == '\"')) {
64         o++;
65         l -= 2;
66     }
67 
68     while (o < l && (*i)[o] <= ' ') {
69         ++o;
70         --l;
71     }
72     while (l > 0 && (*i)[o + l - 1] <= ' ')
73         --l;
74 
75     Vector<UChar, 2048> buffer(l);
76 
77     int nl = 0;
78     for (int k = o; k < o + l; k++) {
79         UChar c = (*i)[k];
80         if (c > '\r')
81             buffer[nl++] = c;
82     }
83 
84     return String(buffer.data(), nl);
85 }
86 
87 } // namespace WebCore
88