File indexing completed on 2024-04-28 11:37:30
0001 /* 0002 * This file is part of the CSS implementation for KDE. 0003 * 0004 * Copyright 1999 Lars Knoll (knoll@kde.org) 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Library General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Library General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Library General Public License 0017 * along with this library; see the file COPYING.LIB. If not, write to 0018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 * 0021 */ 0022 #include "csshelper.h" 0023 0024 #include "misc/helper.h" 0025 #include "xml/dom_stringimpl.h" 0026 0027 using namespace DOM; 0028 using namespace khtml; 0029 0030 DOMString khtml::parseURL(const DOMString &url) 0031 { 0032 DOMStringImpl *i = url.implementation(); 0033 if (!i) { 0034 return DOMString(); 0035 } 0036 0037 int o = 0; 0038 int l = i->l; 0039 while (o < l && (i->s[o] <= ' ')) { 0040 o++; 0041 l--; 0042 } 0043 while (l > 0 && (i->s[o + l - 1] <= ' ')) { 0044 l--; 0045 } 0046 0047 if (l >= 5 && 0048 (i->s[o].toLower() == 'u') && 0049 (i->s[o + 1].toLower() == 'r') && 0050 (i->s[o + 2].toLower() == 'l') && 0051 i->s[o + 3].toLatin1() == '(' && 0052 i->s[o + l - 1].toLatin1() == ')') { 0053 o += 4; 0054 l -= 5; 0055 } 0056 0057 while (o < l && (i->s[o] <= ' ')) { 0058 o++; 0059 l--; 0060 } 0061 while (l > 0 && (i->s[o + l - 1] <= ' ')) { 0062 l--; 0063 } 0064 0065 if (l >= 2 && i->s[o] == i->s[o + l - 1] && 0066 (i->s[o].toLatin1() == '\'' || i->s[o].toLatin1() == '\"')) { 0067 o++; 0068 l -= 2; 0069 } 0070 0071 while (o < l && (i->s[o] <= ' ')) { 0072 o++; 0073 l--; 0074 } 0075 while (l > 0 && (i->s[o + l - 1] <= ' ')) { 0076 l--; 0077 } 0078 0079 DOMStringImpl *j = new DOMStringImpl(i->s + o, l); 0080 0081 int nl = 0; 0082 for (int k = o; k < o + l; k++) 0083 if (i->s[k].unicode() > '\r') { 0084 j->s[nl++] = i->s[k]; 0085 } 0086 0087 j->l = nl; 0088 0089 return j; 0090 }