Commit 99d6e890 authored by Andrea Iacovitti's avatar Andrea Iacovitti

Do not allow uri in css format where it is not allowed and clean up from parseURL() use.

parent 9bb7e125
......@@ -38,8 +38,6 @@
#include "css_mediaquery.h"
#include "cssproperties.h"
#include "cssvalues.h"
#include "csshelper.h"
#include <misc/helper.h>
#include <stdlib.h>
#include <assert.h>
......@@ -2311,9 +2309,8 @@ bool CSSParser::parseFontFaceSrc()
while ((val = valueList->current())) {
CSSFontFaceSrcValueImpl* parsedValue = 0;
if (val->unit == CSSPrimitiveValue::CSS_URI && !expectComma && styleElement) {
DOMString uri = khtml::parseURL( domString( val->string ) );
parsedValue = new CSSFontFaceSrcValueImpl(
DOMString(KUrl( styleElement->baseURL(), uri.string()).url()), false /*local*/);
const QString uri = qString(val->string);
parsedValue = new CSSFontFaceSrcValueImpl(DOMString(KUrl(styleElement->baseURL(), uri).url()), false /*local*/);
uriValue = parsedValue;
allowFormat = true;
expectComma = true;
......
......@@ -22,7 +22,6 @@
// --------------------------------------------------------------------------
#include "html_document.h"
#include "css/csshelper.h"
#include "dom/html_misc.h"
#include "dom/dom_exception.h"
#include "xml/dom_textimpl.h"
......@@ -101,8 +100,7 @@ DOMString HTMLDocument::referrer() const
DOMString HTMLDocument::completeURL(const DOMString& str) const
{
if(!impl) return str;
DOMString parsed = khtml::parseURL(str);
return ((HTMLDocumentImpl *)impl)->completeURL(parsed.string());
return ((HTMLDocumentImpl *)impl)->completeURL(str.string());
}
DOMString HTMLDocument::domain() const
......
......@@ -35,8 +35,6 @@
#include <html/html_canvasimpl.h>
#include <dom/dom_exception.h>
#include <css/csshelper.h> // for parseUrl
#include <html/html_baseimpl.h>
#include <html/html_documentimpl.h>
#include <html/html_formimpl.h>
......@@ -1589,7 +1587,7 @@ QHash<int, const HTMLElement::BoundPropInfo*>* HTMLElement::boundPropInfo()
QString KJS::HTMLElement::getURLArg(unsigned id) const
{
DOMString rel = khtml::parseURL(impl()->getAttribute(id));
const DOMString rel = impl()->getAttribute(id);
return !rel.isNull() ? impl()->document()->completeURL(rel.string()) : QString();
}
......
......@@ -36,7 +36,6 @@
#include "css/css_stylesheetimpl.h"
#include "css/cssproperties.h"
#include "css/cssvalues.h"
#include "css/csshelper.h"
#include "misc/loader.h"
#include "dom/dom_string.h"
#include "dom/dom_doc.h"
......@@ -72,7 +71,7 @@ void HTMLBodyElementImpl::parseAttribute(AttributeImpl *attr)
case ATTR_BACKGROUND:
{
QString url = khtml::parseURL( attr->value() ).string();
QString url = attr->val()->string();
if (!url.isEmpty()) {
url = document()->completeURL( url );
addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, DOMString("url('"+url+"')") );
......@@ -326,7 +325,7 @@ void HTMLFrameElementImpl::parseAttribute(AttributeImpl *attr)
switch(attr->id())
{
case ATTR_SRC:
setLocation(khtml::parseURL(attr->val()));
setLocation(attr->value());
break;
case ATTR_FRAMEBORDER:
{
......@@ -756,7 +755,7 @@ void HTMLIFrameElementImpl::parseAttribute(AttributeImpl *attr )
addHTMLAlignment( attr->value() );
break;
case ATTR_SRC:
url = khtml::parseURL(attr->val());
url = attr->value();
setNeedComputeContent();
// ### synchronously start the process?
break;
......
......@@ -36,7 +36,6 @@
#include "css/cssstyleselector.h"
#include "css/cssproperties.h"
#include "css/cssvalues.h"
#include "css/csshelper.h"
#include "xml/dom_textimpl.h"
#include "xml/dom_docimpl.h"
#include "xml/dom2_eventsimpl.h"
......@@ -680,19 +679,18 @@ void HTMLFormElementImpl::submit( )
}
#endif // KHTML_NO_WALLET
DOMString value = getAttribute(ATTR_ACTION);
DOMString url = khtml::parseURL(value);
QString url = getAttribute(ATTR_ACTION).string();
// ignore base url if 'action' attribute is empty.
if (value.isEmpty())
if (url.isEmpty())
url = formUrl.url();
if(m_post) {
view->part()->submitForm( "post", url.string(), form_data,
view->part()->submitForm( "post", url, form_data,
m_target.string(),
enctype().string(),
m_boundary );
}
else {
view->part()->submitForm( "get", url.string(), form_data,
view->part()->submitForm( "get", url, form_data,
m_target.string() );
}
}
......
......@@ -32,11 +32,9 @@
#include "khtml_part.h"
#include "misc/loader.h"
#include "misc/helper.h"
#include "css/cssstyleselector.h"
#include "css/css_stylesheetimpl.h"
#include "css/csshelper.h"
#include "css/css_mediaquery.h"
#include "ecma/kjs_proxy.h"
......@@ -57,7 +55,7 @@ void HTMLBaseElementImpl::parseAttribute(AttributeImpl *attr)
switch(attr->id())
{
case ATTR_HREF:
m_href = khtml::parseURL(attr->value());
m_href = attr->value();
process();
break;
case ATTR_TARGET:
......@@ -118,7 +116,7 @@ void HTMLLinkElementImpl::parseAttribute(AttributeImpl *attr)
switch (attr->id())
{
case ATTR_HREF:
m_url = document()->completeURL( khtml::parseURL(attr->value()).string() );
m_url = document()->completeURL(attr->val()->string());
process();
break;
case ATTR_REL:
......
......@@ -30,7 +30,6 @@
#include "khtmlview.h"
#include "khtml_part.h"
#include "css/csshelper.h"
#include "css/cssproperties.h"
#include "css/cssvalues.h"
#include "css/cssstyleselector.h"
......@@ -67,8 +66,6 @@ void HTMLAnchorElementImpl::defaultEventHandler(EventImpl *evt)
if (keydown)
k = static_cast<KeyEventBaseImpl *>( evt );
QString utarget;
QString url;
if ( e && e->button() == 2 ) {
HTMLElementImpl::defaultEventHandler(evt);
return;
......@@ -84,9 +81,8 @@ void HTMLAnchorElementImpl::defaultEventHandler(EventImpl *evt)
if (k->qKeyEvent()) k->qKeyEvent()->accept();
}
url = khtml::parseURL(getAttribute(ATTR_HREF)).string();
utarget = getAttribute(ATTR_TARGET).string();
QString url = getAttribute(ATTR_HREF).string();
QString utarget = getAttribute(ATTR_TARGET).string();
if ( e && e->button() == 1 )
utarget = "_blank";
......
......@@ -40,7 +40,6 @@
#include "xml/dom_docimpl.h"
#include "css/cssstyleselector.h"
#include "css/csshelper.h"
#include "css/cssproperties.h"
#include "css/cssvalues.h"
#include "rendering/render_frames.h"
......@@ -696,7 +695,7 @@ void HTMLEmbedElementImpl::parseAttribute(AttributeImpl *attr)
{
case ATTR_CODE:
case ATTR_SRC:
url = khtml::parseURL(attr->val()).string();
url = attr->val()->string();
setNeedComputeContent();
break;
case ATTR_BORDER:
......@@ -776,7 +775,7 @@ void HTMLObjectElementImpl::parseAttribute(AttributeImpl *attr)
switch ( attr->id() )
{
case ATTR_DATA:
url = khtml::parseURL( attr->val() ).string();
url = attr->val()->string();
setNeedComputeContent();
break;
case ATTR_CLASSID:
......
......@@ -38,7 +38,6 @@
#include <css/cssstyleselector.h>
#include <css/cssproperties.h>
#include <css/cssvalues.h>
#include <css/csshelper.h>
#include <rendering/render_table.h>
......@@ -496,8 +495,8 @@ void HTMLTableElementImpl::parseAttribute(AttributeImpl *attr)
break;
case ATTR_BACKGROUND:
{
if (!attr->value().isEmpty()) {
QString url = khtml::parseURL( attr->value() ).string();
QString url = attr->val()->string();
if (!url.isEmpty()) {
url = document()->completeURL( url );
addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, DOMString("url('"+url+"')") );
}
......@@ -639,8 +638,8 @@ void HTMLTablePartElementImpl::parseAttribute(AttributeImpl *attr)
break;
case ATTR_BACKGROUND:
{
if (attr->val()) {
QString url = khtml::parseURL( attr->value() ).string();
QString url = attr->val()->string();
if (!url.isEmpty()) {
url = document()->completeURL( url );
addCSSProperty(CSS_PROP_BACKGROUND_IMAGE, DOMString("url('"+url+"')") );
}
......
......@@ -55,7 +55,6 @@
#include <khtml_global.h>
#include <css/cssproperties.h>
#include <css/cssvalues.h>
#include <css/csshelper.h>
#include <rendering/render_object.h>
......@@ -975,7 +974,8 @@ NodeImpl *KHTMLParser::getElement(Token* t)
KHTMLGlobal::defaultHTMLSettings()->isHideAdsEnabled() &&
!strcasecmp( t->attrs->getValue( ATTR_TYPE ), "image" ) )
{
if (KHTMLGlobal::defaultHTMLSettings()->isAdFiltered( doc()->completeURL( khtml::parseURL(t->attrs->getValue(ATTR_SRC)).string() ) ))
const QString url = doc()->completeURL(t->attrs->getValue(ATTR_SRC)->string());
if (KHTMLGlobal::defaultHTMLSettings()->isAdFiltered(url))
return 0;
}
n = new HTMLInputElementImpl(document, form);
......@@ -1104,7 +1104,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
KHTMLGlobal::defaultHTMLSettings()->isAdFilterEnabled()&&
KHTMLGlobal::defaultHTMLSettings()->isHideAdsEnabled())
{
QString url = doc()->completeURL( khtml::parseURL(t->attrs->getValue(ATTR_SRC)).string() );
const QString url = doc()->completeURL(t->attrs->getValue(ATTR_SRC)->string());
if (KHTMLGlobal::defaultHTMLSettings()->isAdFiltered(url))
return 0;
}
......
......@@ -706,7 +706,7 @@ void ProspectiveTokenizer::processAttribute()
LocalName attrLocal = LocalName::fromString(&attrDS, IDS_NormalizeLower);
uint attribute = attrLocal.id();
if (attribute == localNamePart(ATTR_SRC) && m_urlToLoad.isEmpty())
m_urlToLoad = parseURL(DOMString(m_attributeValue.data(), m_attributeValue.size()));
m_urlToLoad = DOMString(m_attributeValue.data(), m_attributeValue.size());
break;
}
case ID_LINK:
......@@ -715,7 +715,7 @@ void ProspectiveTokenizer::processAttribute()
LocalName attrLocal = LocalName::fromString(&attrDS, IDS_NormalizeLower);
uint attribute = attrLocal.id();
if (attribute == localNamePart(ATTR_HREF) && m_urlToLoad.isEmpty())
m_urlToLoad = parseURL(DOMString(m_attributeValue.data(), m_attributeValue.size()));
m_urlToLoad = DOMString(m_attributeValue.data(), m_attributeValue.size());
else if (attribute == localNamePart(ATTR_REL)) {
DOMStringImpl* lowerAttribute = DOMStringImpl(DOMStringImpl::ShallowCopy, m_attributeValue.data(), m_attributeValue.size()).lower();
QString val = lowerAttribute->string();
......
......@@ -57,7 +57,6 @@
#include "xml/dom2_rangeimpl.h"
#include "xml/xml_tokenizer.h"
#include "css/cssstyleselector.h"
#include "css/csshelper.h"
using namespace DOM;
#include "khtmlview.h"
......@@ -6402,14 +6401,13 @@ bool KHTMLPart::handleMouseMoveEventDrag(khtml::MouseMoveEvent *event)
if (!dndEnabled())
return false;
DOM::Node innerNode = event->innerNode();
if( (d->m_bMousePressed &&
( (!d->m_strSelectedURL.isEmpty() && !isEditable())
|| (!d->m_mousePressNode.isNull() && d->m_mousePressNode.elementId() == ID_IMG) ) )
&& ( d->m_dragStartPos - QPoint(event->x(), event->y()) ).manhattanLength() > KGlobalSettings::dndEventDelay() ) {
DOM::DOMString url = event->url();
const DOM::DOMString url = event->url();
DOM::NodeImpl* innerNodeImpl = event->innerNode().handle();
QPixmap pix;
HTMLImageElementImpl *img = 0L;
......@@ -6419,10 +6417,10 @@ bool KHTMLPart::handleMouseMoveEventDrag(khtml::MouseMoveEvent *event)
// qDebug("****************** Event Target: %s", target.string().toLatin1().constData());
// Normal image...
if ( url.length() == 0 && innerNode.handle() && innerNode.handle()->id() == ID_IMG )
if (url.isEmpty() && innerNodeImpl && innerNodeImpl->id() == ID_IMG)
{
img = static_cast<HTMLImageElementImpl *>(innerNode.handle());
u = KUrl( completeURL( khtml::parseURL(img->getAttribute(ATTR_SRC)).string() ) );
img = static_cast<HTMLImageElementImpl *>(innerNodeImpl);
u = completeURL(img->getAttribute(ATTR_SRC).string());
pix = KIconLoader::global()->loadIcon("image-x-generic", KIconLoader::Desktop);
}
else
......
......@@ -55,8 +55,6 @@
#undef protected
#include "xml/dom2_eventsimpl.h"
#include "css/cssstyleselector.h"
#include "css/csshelper.h"
#include "misc/helper.h"
#include "misc/loader.h"
#include "khtml_settings.h"
#include "khtml_printsettings.h"
......@@ -2782,7 +2780,7 @@ QMap< ElementImpl*, QChar > KHTMLView::buildFallbackAccessKeys() const
bool text_before = false;
switch( element->id()) {
case ID_A:
url = khtml::parseURL(element->getAttribute(ATTR_HREF)).string();
url = element->getAttribute(ATTR_HREF).string();
if( url.isEmpty()) // doesn't have href, it's only an anchor
continue;
text = static_cast< HTMLElementImpl* >( element )->innerText().string().simplified();
......
......@@ -34,8 +34,6 @@
#include <kdebug.h>
#include <kglobalsettings.h>
#include "css/csshelper.h"
#include "misc/helper.h"
#include "misc/loader.h"
#include "html/html_formimpl.h"
#include "html/html_imageimpl.h"
......@@ -434,8 +432,7 @@ void RenderImage::updateFromElement()
if (!u.isEmpty() &&
( !m_cachedImage || m_cachedImage->url() != u ) ) {
CachedImage *new_image = element()->document()->docLoader()->
requestImage(khtml::parseURL(u));
CachedImage *new_image = element()->document()->docLoader()->requestImage(u);
if(new_image && new_image != m_cachedImage)
updateImage( new_image );
......
......@@ -37,10 +37,8 @@
#include <html/htmltokenizer.h>
#include "dom_restyler.h"
#include <css/csshelper.h>
#include <css/cssstyleselector.h>
#include <css/css_stylesheetimpl.h>
#include <misc/helper.h>
#include <misc/seed.h>
#include <misc/loader.h>
#include <ecma/kjs_proxy.h>
......@@ -1986,10 +1984,9 @@ void DocumentImpl::processHttpEquiv(const DOMString &equiv, const DOMString &con
if(str.indexOf("url", 0, Qt::CaseInsensitive ) == 0) str = str.mid(3);
str = str.trimmed();
if ( str.length() && str[0] == '=' ) str = str.mid( 1 ).trimmed();
while(str.length() &&
(str[str.length()-1] == ';' || str[str.length()-1] == ','))
while (str.length() && (str[str.length()-1] == ';' || str[str.length()-1] == ',')) {
str.resize(str.length()-1);
str = parseURL( DOMString(str) ).string();
}
QString newURL = document()->completeURL( str );
if ( ok )
v->part()->scheduleRedirection(delay, newURL, delay < 2 || newURL == URL().url());
......@@ -2050,7 +2047,7 @@ bool DocumentImpl::prepareMouseEvent( bool readonly, int _x, int _y, MouseEvent
//qDebug("urlnode: %s (%d)", getTagName(renderInfo.URLElement()->id()).string().toLatin1().constData(), renderInfo.URLElement()->id());
ElementImpl* e = static_cast<ElementImpl*>(renderInfo.URLElement());
DOMString href = khtml::parseURL(e->getAttribute(ATTR_HREF));
DOMString href = e->getAttribute(ATTR_HREF);
DOMString target = e->getAttribute(ATTR_TARGET);
if (!target.isNull() && !href.isNull()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment