// Right now, only one item for each action. void subversionCore::svnLog( const KURL::List& list, int revstart, QString revKindStart, int revend, QString revKindEnd, bool discorverChangedPath, bool strictNodeHistory ) { // ensure that part has repository information. This info is used to retrieve root repository URL if( m_part->m_prjInfoMap.count() < 1 ) clientInfo( KURL(m_part->project()->projectDirectory()), false, m_part->m_prjInfoMap ); KURL servURL = m_part->baseURL(); if ( servURL.isEmpty() ) servURL="kdevsvn+svn://blah/"; if ( ! servURL.protocol().startsWith( "kdevsvn+" ) ) { servURL.setProtocol( "kdevsvn+" + servURL.protocol() ); //make sure it starts with "svn" } kdDebug(9036) << "servURL : " << servURL.prettyURL() << endl; QByteArray parms; QDataStream s( parms, IO_WriteOnly ); // prepare arguments int cmd = 4; // int revstart = -1, revend = 0; // QString revKindStart = "HEAD", revKindEnd = ""; // bool repositLog = true, discorverChangedPath = true, strictNodeHistory = true; s << cmd << revstart << revKindStart << revend << revKindEnd; s << discorverChangedPath << strictNodeHistory; for ( QValueListConstIterator<KURL> it = list.begin(); it != list.end() ; ++it ) { kdDebug(9036) << "svnCore: adding to list: " << (*it).prettyURL() << endl; s << *it; } SimpleJob * job = KIO::special(servURL, parms, false); connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotLogResult( KIO::Job * ) ) ); // progress info. LogView is allowed and meaninful only for one url in KDev3.4 initProcessDlg( (KIO::Job*)job, (*(list.begin())).prettyURL() , i18n("Subversion Log View") ); }
bool HelixEngine::canDecode( const KURL &url ) const { if (!m_inited) return false; debug() << "In canDecode " << url.prettyURL() << endl; if (url.protocol() == "http" || url.protocol() == "rtsp") return true; const QString path = url.path(); const QString ext = path.mid( path.findRev( '.' ) + 1 ).lower(); if (ext != "txt") for (int i=0; i<(int)m_mimes.size(); i++) { if (m_mimes[i].type.grep("audio").count() || m_mimes[i].type.grep("video").count() || m_mimes[i].type.grep("application").count()) if (m_mimes[i].ext.grep(ext).count()) { return true; } } return false; }
static String originStringFromURL(const KURL& url) { if (url.port()) return url.protocol() + "://" + url.host() + ':' + String::number(url.port()) + '/'; return url.protocol() + "://" + url.host() + '/'; }
void MediaProtocol::rename(const KURL &src, const KURL &dest, bool overwrite) { kdDebug(1219) << "MediaProtocol::rename: " << src << ", " << dest << ", " << overwrite << endl; QString src_name, src_path; bool ok = m_impl.parseURL(src, src_name, src_path); QString dest_name, dest_path; ok &= m_impl.parseURL(dest, dest_name, dest_path); if ( ok && src_path.isEmpty() && dest_path.isEmpty() && src.protocol() == "media" && dest.protocol() == "media" ) { if (!m_impl.setUserLabel(src_name, dest_name)) { error(m_impl.lastErrorCode(), m_impl.lastErrorMessage()); } else { finished(); } } else { ForwardingSlaveBase::rename(src, dest, overwrite); } }
KURL* toDAV( const KURL* url ) { KURL* result = new KURL( *url ); if ( result->protocol() == "http" ) result->setProtocol( "webdav" ); else if ( result->protocol() == "https" ) result->setProtocol( "webdavs" ); return result; }
bool protocolHostAndPortAreEqual(const KURL& a, const KURL& b) { if (!a.isValid() || !b.isValid()) return false; return a.protocol() == b.protocol() && a.host() == b.host() && a.port() == b.port(); }
bool CSPSource::schemeMatches(const KURL& url) const { if (m_scheme.isEmpty()) return m_policy->protocolMatchesSelf(url); if (equalIgnoringCase(m_scheme, "http")) return equalIgnoringCase(url.protocol(), "http") || equalIgnoringCase(url.protocol(), "https"); if (equalIgnoringCase(m_scheme, "ws")) return equalIgnoringCase(url.protocol(), "ws") || equalIgnoringCase(url.protocol(), "wss"); return equalIgnoringCase(url.protocol(), m_scheme); }
bool CSPSource::matches(const KURL& url, ResourceRequest::RedirectStatus redirectStatus) const { bool schemesMatch = m_scheme.isEmpty() ? m_policy->protocolMatchesSelf(url) : schemeMatches(url.protocol()); if (!schemesMatch) return false; if (isSchemeOnly()) return true; bool pathsMatch = (redirectStatus == RedirectStatus::FollowedRedirect) || pathMatches(url.path()); return hostMatches(url.host()) && portMatches(url.port(), url.protocol()) && pathsMatch; }
void HTMLMetaElementImpl::attach(KHTMLView *v) { setStyle(document->styleSelector()->styleForElement(this)); // kdDebug() << "meta::attach() equiv=" << _equiv.string() << ", content=" << _content.string() << endl; if(strcasecmp(_equiv, "refresh") == 0 && !_content.isNull() && v->part()->metaRefreshEnabled()) { // get delay and url QString str = _content.string(); int pos = str.find(QRegExp("[;,]")); if (pos == -1) // There can be no url (David) { int delay = str.stripWhiteSpace().toInt(); // kdDebug( ) << "delay = " << delay << endl; // kdDebug( ) << "====> scheduling redirect to " << v->part()->url().url() << endl; v->part()->scheduleRedirection(delay, v->part()->url().url()); } else { int delay = str.left(pos).stripWhiteSpace().toInt(); // kdDebug( ) << "delay = " << delay << ", separator at " << pos << endl; pos++; while(pos < (int)str.length() && str[pos].isSpace()) pos++; if(pos < (int)str.length()) str = str.mid(pos); if(strncasecmp(str, "url=", 4) == 0) str = str.mid(4).simplifyWhiteSpace(); str = parseURL( DOMString(str) ).string(); // kdDebug( ) << "====> got redirect to " << str << endl; v->part()->scheduleRedirection(delay, str); } } else if(strcasecmp(_equiv, "expires") == 0 && !_content.isNull()) { QString str = _content.string().stripWhiteSpace(); time_t expire_date = str.toLong(); KURL url = v->part()->url(); if (url.protocol().startsWith("http")) { // KIO::http_update_cache(m_url, false, d->m_doc->docLoader()->expire_date); // moved to khtml_part.cpp::slotFinished(KIO::Job *) (Tobias) if (document->docLoader()) document->docLoader()->setExpireDate(expire_date); } } else if(strcasecmp(_equiv, "pragma") == 0 && !_content.isNull()) { QString str = _content.string().lower().stripWhiteSpace(); KURL url = v->part()->url(); if ((str == "no-cache") && url.protocol().startsWith("http")) { KIO::http_update_cache(url, true, 0); } } NodeBaseImpl::attach( v ); }
void TrashProtocol::rename(const KURL &oldURL, const KURL &newURL, bool overwrite) { INIT_IMPL; kdDebug() << "TrashProtocol::rename(): old=" << oldURL << " new=" << newURL << " overwrite=" << overwrite << endl; if(oldURL.protocol() == "trash" && newURL.protocol() == "trash") { error(KIO::ERR_CANNOT_RENAME, oldURL.prettyURL()); return; } copyOrMove(oldURL, newURL, overwrite, Move); }
void TrashProtocol::copy(const KURL &src, const KURL &dest, int /*permissions*/, bool overwrite) { INIT_IMPL; kdDebug() << "TrashProtocol::copy(): " << src << " " << dest << endl; if(src.protocol() == "trash" && dest.protocol() == "trash") { error(KIO::ERR_UNSUPPORTED_ACTION, i18n("This file is already in the trash bin.")); return; } copyOrMove(src, dest, overwrite, Copy); }
static bool shouldTreatAsUniqueOrigin(const KURL& url) { if (!url.isValid()) return true; // FIXME: Do we need to unwrap the URL further? KURL innerURL = shouldUseInnerURL(url) ? extractInnerURL(url) : url; // FIXME: Check whether innerURL is valid. // For edge case URLs that were probably misparsed, make sure that the origin is unique. // FIXME: Do we really need to do this? This looks to be a hack around a // security bug in CFNetwork that might have been fixed. if (schemeRequiresAuthority(innerURL) && innerURL.host().isEmpty()) return true; // SchemeRegistry needs a lower case protocol because it uses HashMaps // that assume the scheme has already been canonicalized. String protocol = innerURL.protocol().lower(); if (SchemeRegistry::shouldTreatURLSchemeAsNoAccess(protocol)) return true; // This is the common case. return false; }
bool KGlobalSettings::showFilePreview(const KURL &url) { KConfigGroup g(KGlobal::config(), "PreviewSettings"); QString protocol = url.protocol(); bool defaultSetting = KProtocolInfo::showFilePreview( protocol ); return g.readBoolEntry(protocol, defaultSetting ); }
String cookies(const KURL& url) { #if USE(CFNETWORK) CFHTTPCookieStorageRef defaultCookieStorage = wkGetDefaultHTTPCookieStorage(); if (!defaultCookieStorage) return String(); String cookieString; RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL()); bool secure = equalIgnoringCase(url.protocol(), "https"); RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(defaultCookieStorage, urlCF.get(), secure)); RetainPtr<CFDictionaryRef> headerCF(AdoptCF, CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, cookiesCF.get())); return (CFStringRef)CFDictionaryGetValue(headerCF.get(), s_cookieCF); #else DeprecatedString str = url.url(); str.append((UChar)'\0'); DWORD count = str.length(); InternetGetCookie((UChar*)str.unicode(), 0, 0, &count); if (count <= 1) // Null terminator counts as 1. return String(); UChar* buffer = new UChar[count]; InternetGetCookie((UChar*)str.unicode(), 0, buffer, &count); String& result = String(buffer, count-1); // Ignore the null terminator. delete[] buffer; return result; #endif }
String cookies(const Document* /*document*/, const KURL& url) { CFHTTPCookieStorageRef cookieStorage = currentCookieStorage(); if (!cookieStorage) return String(); String cookieString; RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL()); bool secure = equalIgnoringCase(url.protocol(), "https"); RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieStorageCopyCookiesForURL(cookieStorage, urlCF.get(), secure)); // <rdar://problem/5632883> CFHTTPCookieStorage happily stores an empty cookie, which would be sent as "Cookie: =". // We have a workaround in setCookies() to prevent that, but we also need to avoid sending cookies that were previously stored. CFIndex count = CFArrayGetCount(cookiesCF.get()); RetainPtr<CFMutableArrayRef> cookiesForURLFilteredCopy(AdoptCF, CFArrayCreateMutable(0, count, &kCFTypeArrayCallBacks)); for (CFIndex i = 0; i < count; ++i) { CFHTTPCookieRef cookie = (CFHTTPCookieRef)CFArrayGetValueAtIndex(cookiesCF.get(), i); if (CFStringGetLength(CFHTTPCookieGetName(cookie)) != 0) CFArrayAppendValue(cookiesForURLFilteredCopy.get(), cookie); } RetainPtr<CFDictionaryRef> headerCF(AdoptCF, CFHTTPCookieCopyRequestHeaderFields(kCFAllocatorDefault, cookiesForURLFilteredCopy.get())); return (CFStringRef)CFDictionaryGetValue(headerCF.get(), s_cookieCF); }
IconURL IconController::defaultURL(IconType iconType) { // Don't return a favicon iconURL unless we're http or https KURL documentURL = m_frame->document()->url(); if (!documentURL.protocolIsInHTTPFamily()) return IconURL(); KURL url; bool couldSetProtocol = url.setProtocol(documentURL.protocol()); ASSERT_UNUSED(couldSetProtocol, couldSetProtocol); url.setHost(documentURL.host()); if (documentURL.hasPort()) url.setPort(documentURL.port()); if (iconType == Favicon) { url.setPath("/favicon.ico"); return IconURL::defaultIconURL(url, Favicon); } #if ENABLE(TOUCH_ICON_LOADING) if (iconType == TouchPrecomposedIcon) { url.setPath("/apple-touch-icon-precomposed.png"); return IconURL::defaultIconURL(url, TouchPrecomposedIcon); } if (iconType == TouchIcon) { url.setPath("/apple-touch-icon.png"); return IconURL::defaultIconURL(url, TouchIcon); } #endif return IconURL(); }
void HTMLView::openURLRequest( const KURL &url ) { // here, http urls are streams. For webpages we use externalurl // NOTE there have been no links to streams! http now used for wiki tab. if ( url.protocol() == "file" ) Playlist::instance()->insertMedia( url, Playlist::DefaultOptions ); }
ObjectContentType FrameLoaderClientEfl::objectContentType(const KURL& url, const String& mimeType) { if (url.isEmpty() && mimeType.isEmpty()) return ObjectContentNone; // We don't use MIMETypeRegistry::getMIMETypeForPath() because it returns "application/octet-stream" upon failure String type = mimeType; if (type.isEmpty()) type = MIMETypeRegistry::getMIMETypeForExtension(url.path().substring(url.path().reverseFind('.') + 1)); if (type.isEmpty()) return ObjectContentFrame; if (MIMETypeRegistry::isSupportedImageMIMEType(type)) return ObjectContentImage; #if 0 // PluginDatabase is disabled until we have Plugin system done. if (PluginDatabase::installedPlugins()->isMIMETypeRegistered(mimeType)) return ObjectContentNetscapePlugin; #endif if (MIMETypeRegistry::isSupportedNonImageMIMEType(type)) return ObjectContentFrame; if (url.protocol() == "about") return ObjectContentFrame; return ObjectContentNone; }
void Page::userStyleSheetLocationChanged() { // FIXME: Eventually we will move to a model of just being handed the sheet // text instead of loading the URL ourselves. KURL url = m_settings->userStyleSheetLocation(); // Allow any local file URL scheme to be loaded. if (SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol())) m_userStyleSheetPath = url.fileSystemPath(); else m_userStyleSheetPath = String(); m_didLoadUserStyleSheet = false; m_userStyleSheet = String(); m_userStyleSheetModificationTime = 0; // Data URLs with base64-encoded UTF-8 style sheets are common. We can process them // synchronously and avoid using a loader. if (url.protocolIsData() && url.string().startsWith("data:text/css;charset=utf-8;base64,")) { m_didLoadUserStyleSheet = true; Vector<char> styleSheetAsUTF8; if (base64Decode(decodeURLEscapeSequences(url.string().substring(35)), styleSheetAsUTF8, Base64IgnoreWhitespace)) m_userStyleSheet = String::fromUTF8(styleSheetAsUTF8.data(), styleSheetAsUTF8.size()); } for (Frame* frame = mainFrame(); frame; frame = frame->tree()->traverseNext()) { if (frame->document()) frame->document()->styleSheetCollection()->updatePageUserSheet(); } }
AtomicURL::AtomicURL( const KURL &url ) { if( url.isEmpty() ) return; QString s = url.protocol() + "://"; QString host = url.host(); if( url.hasUser() ) { s += url.user(); host.prepend("@"); } if( url.hasPass() ) s += ':' + url.pass(); if( url.port() ) host += QString(":") + QString::number( url.port() ); m_beginning = s + host; m_directory = url.directory(); m_filename = url.fileName(); m_end = url.query(); if( url.hasRef() ) m_end += QString("#") + url.ref(); if (url != this->url()) { debug() << "from: " << url << endl; debug() << "to: " << this->url() << endl; } }
void RemoteProtocol::rename(const KURL &src, const KURL &dest, bool overwrite) { if(src.protocol() != "remote" || dest.protocol() != "remote" || m_impl.isWizardURL(src) || m_impl.isWizardURL(dest)) { error(KIO::ERR_UNSUPPORTED_ACTION, src.prettyURL()); return; } if(m_impl.renameFolders(src.fileName(), dest.fileName(), overwrite)) { finished(); return; } error(KIO::ERR_CANNOT_RENAME, src.prettyURL()); }
void HTMLAnchorElement::setHost(const String& value) { if (value.isEmpty()) return; KURL url = href(); if (!url.canSetHostOrPort()) return; size_t separator = value.find(':'); if (!separator) return; if (separator == notFound) url.setHostAndPort(value); else { unsigned portEnd; unsigned port = parsePortFromStringPosition(value, separator + 1, portEnd); if (!port) { // http://dev.w3.org/html5/spec/infrastructure.html#url-decomposition-idl-attributes // specifically goes against RFC 3986 (p3.2) and // requires setting the port to "0" if it is set to empty string. url.setHostAndPort(value.substring(0, separator + 1) + "0"); } else { if (isDefaultPortForProtocol(port, url.protocol())) url.setHostAndPort(value.substring(0, separator)); else url.setHostAndPort(value.substring(0, portEnd)); } } setHref(url.string()); }
ObjectContentType FrameLoaderClientQt::objectContentType(const KURL& url, const String& _mimeType) { // qDebug()<<" ++++++++++++++++ url is "<<url.prettyURL()<<", mime = "<<_mimeType; if (_mimeType == "application/x-qt-plugin" || _mimeType == "application/x-qt-styled-widget") return ObjectContentOtherPlugin; if (url.isEmpty() && !_mimeType.length()) return ObjectContentNone; String mimeType = _mimeType; if (!mimeType.length()) { QFileInfo fi(url.path()); mimeType = MIMETypeRegistry::getMIMETypeForExtension(fi.suffix()); } if (!mimeType.length()) return ObjectContentFrame; if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) return ObjectContentImage; if (PluginDatabase::installedPlugins()->isMIMETypeRegistered(mimeType)) return ObjectContentNetscapePlugin; if (m_frame->page() && m_frame->page()->pluginData() && m_frame->page()->pluginData()->supportsMimeType(mimeType)) return ObjectContentOtherPlugin; if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)) return ObjectContentFrame; if (url.protocol() == "about") return ObjectContentFrame; return ObjectContentNone; }
String DOMURLUtilsReadOnly::host(const KURL& kurl) { if (kurl.hostEnd() == kurl.pathStart()) return kurl.host(); if (isDefaultPortForProtocol(kurl.port(), kurl.protocol())) return kurl.host(); return kurl.host() + ":" + String::number(kurl.port()); }
ObjectContentType FrameLoaderClientEfl::objectContentType(const KURL& url, const String& mimeType, bool shouldPreferPlugInsForImages) { // FIXME: once plugin support is enabled, this method needs to correctly handle the 'shouldPreferPlugInsForImages' flag. See // WebCore::FrameLoader::defaultObjectContentType() for an example. UNUSED_PARAM(shouldPreferPlugInsForImages); if (url.isEmpty() && mimeType.isEmpty()) return ObjectContentNone; // We don't use MIMETypeRegistry::getMIMETypeForPath() because it returns "application/octet-stream" upon failure String type = mimeType; if (type.isEmpty()) type = MIMETypeRegistry::getMIMETypeForExtension(url.path().substring(url.path().reverseFind('.') + 1)); if (type.isEmpty()) return ObjectContentFrame; if (MIMETypeRegistry::isSupportedImageMIMEType(type)) return ObjectContentImage; #if 0 // PluginDatabase is disabled until we have Plugin system done. if (PluginDatabase::installedPlugins()->isMIMETypeRegistered(mimeType)) return ObjectContentNetscapePlugin; #endif if (MIMETypeRegistry::isSupportedNonImageMIMEType(type)) return ObjectContentFrame; if (url.protocol() == "about") return ObjectContentFrame; return ObjectContentNone; }
bool PreviewJob::statResultThumbnail() { if ( d->thumbPath.isEmpty() ) return false; KURL url = d->currentItem.item->url(); // Don't include the password if any url.setPass(TQString::null); // The TMS defines local files as file:///path/to/file instead of KDE's // way (file:/path/to/file) #ifdef KURL_TRIPLE_SLASH_FILE_PROT d->origName = url.url(); #else if (url.protocol() == "file") d->origName = "file://" + url.path(); else d->origName = url.url(); #endif KMD5 md5( TQFile::encodeName( d->origName ).data() ); d->thumbName = TQFile::encodeName( md5.hexDigest() ) + ".png"; TQImage thumb; if ( !thumb.load( d->thumbPath + d->thumbName ) ) return false; if ( thumb.text( "Thumb::URI", 0 ) != d->origName || thumb.text( "Thumb::MTime", 0 ).toInt() != d->tOrig ) return false; // Found it, use it emitPreview( thumb ); d->succeeded = true; determineNextFile(); return true; }
QString Groupwise::soapUrl(const KURL &url) { // FIXME: Get SSL from parameter bool useSsl = url.protocol() == "groupwises"; QString u; if(useSsl) u = "https"; else u = "http"; u += "://" + url.host() + ":"; if(url.port()) u += QString::number(url.port()); else { u += "7191"; } // check for a soap path in the URL // assume that if a path to soap is included in the URL, // it will be at the start of the path, eg. // groupwise://host:port/soap2/freebusy if(!(url.path().startsWith("/freebusy/") || url.path().startsWith("/calendar/") || url.path().startsWith("/addressbook/"))) { QString soapPath = QString("/") + QStringList::split('/', url.path())[0]; u += soapPath; } else u += "/soap"; return u; }
bool ResourceHandle::start(Frame* frame) { ASSERT(!d->m_msg); // If we are no longer attached to a Page, this must be an attempted load from an // onUnload handler, so let's just block it. if (!frame->page()) return false; KURL url = request().url(); String urlString = url.string(); String protocol = url.protocol(); if (equalIgnoringCase(protocol, "data")) return startData(urlString); else if (equalIgnoringCase(protocol, "http") || equalIgnoringCase(protocol, "https")) return startHttp(urlString); else if (equalIgnoringCase(protocol, "file") || equalIgnoringCase(protocol, "ftp") || equalIgnoringCase(protocol, "ftps")) // FIXME: should we be doing any other protocols here? return startGio(urlString); else { // If we don't call didFail the job is not complete for webkit even false is returned. if (d->client()) { ResourceError error("webkit-network-error", ERROR_UNKNOWN_PROTOCOL, urlString, protocol); d->client()->didFail(this, error); } return false; } }
bool portMatches(const KURL& url) const { if (m_portHasWildcard) return true; int port = url.port(); return port ? port == m_port : isDefaultPortForProtocol(m_port, url.protocol()); }
// Helper method. Parses a trash URL with the URL scheme defined in makeURL. // The trash:/ URL itself isn't parsed here, must be caught by the caller before hand. bool TrashImpl::parseURL( const KURL& url, int& trashId, TQString& fileId, TQString& relativePath ) { if ( url.protocol() != "trash" ) return false; const TQString path = url.path(); int start = 0; if ( path[0] == '/' ) // always true I hope start = 1; int slashPos = path.find( '-', 0 ); // don't match leading slash if ( slashPos <= 0 ) return false; bool ok = false; trashId = path.mid( start, slashPos - start ).toInt( &ok ); Q_ASSERT( ok ); if ( !ok ) return false; start = slashPos + 1; slashPos = path.find( '/', start ); if ( slashPos <= 0 ) { fileId = path.mid( start ); relativePath = TQString::null; return true; } fileId = path.mid( start, slashPos - start ); relativePath = path.mid( slashPos + 1 ); return true; }