示例#1
0
bool DccTransferRecv::createDirs( const KURL& dirURL ) const
{
    KURL kurl( dirURL );
    QString surl = kurl.url();

    //First we split directories until we reach to the top,
    //since we need to create directories one by one

    QStringList dirList;
    while ( surl != kurl.upURL().url() )
    {
        dirList.prepend( surl );
        kurl = kurl.upURL();
        surl = kurl.url();
    }

    //Now we create the directories

    QStringList::ConstIterator it;
    for ( it=dirList.begin() ; it!=dirList.end() ; ++it )
        if ( !KIO::NetAccess::exists( *it, true, NULL ) )
            if ( !KIO::NetAccess::mkdir( *it, NULL, -1 ) )
                return false;

    return true;
}
示例#2
0
void InspectorPageAgent::searchInResource(ErrorString*, const String& frameId, const String& url, const String& query, const bool* const optionalCaseSensitive, const bool* const optionalIsRegex, RefPtr<TypeBuilder::Array<TypeBuilder::Page::SearchMatch> >& results)
{
    results = TypeBuilder::Array<TypeBuilder::Page::SearchMatch>::create();

    bool isRegex = optionalIsRegex ? *optionalIsRegex : false;
    bool caseSensitive = optionalCaseSensitive ? *optionalCaseSensitive : false;

    LocalFrame* frame = frameForId(frameId);
    KURL kurl(ParsedURLString, url);

    FrameLoader* frameLoader = frame ? &frame->loader() : 0;
    DocumentLoader* loader = frameLoader ? frameLoader->documentLoader() : 0;
    if (!loader)
        return;

    String content;
    bool success = false;
    Resource* resource = cachedResource(frame, kurl);
    if (resource)
        success = textContentForResource(resource, &content);

    if (!success)
        return;

    results = ContentSearchUtils::searchInTextByLines(content, query, caseSensitive, isRegex);
}
// MediaPlayer -------------------------------------------------
void WebMediaPlayerClientImpl::load(WebMediaPlayer::LoadType loadType, const WTF::String& url, WebMediaPlayer::CORSMode corsMode)
{
    ASSERT(!m_webMediaPlayer);

    // FIXME: Remove this cast
    LocalFrame* frame = mediaElement().document().frame();

    WebURL poster = m_client->mediaPlayerPosterURL();

    KURL kurl(ParsedURLString, url);
    m_webMediaPlayer = createWebMediaPlayer(this, kurl, frame, HTMLMediaElementEncryptedMedia::contentDecryptionModule(mediaElement()));
    if (!m_webMediaPlayer)
        return;

    if (mediaElement().layoutObject())
        mediaElement().layoutObject()->setShouldDoFullPaintInvalidation();

#if ENABLE(WEB_AUDIO)
    // Make sure if we create/re-create the WebMediaPlayer that we update our wrapper.
    m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider());
#endif

    m_webMediaPlayer->setVolume(mediaElement().effectiveMediaVolume());

    m_webMediaPlayer->setPoster(poster);

    setPreload(mediaElement().effectivePreloadType());

    m_webMediaPlayer->load(loadType, kurl, corsMode);

    if (mediaElement().isFullscreen())
        m_webMediaPlayer->enterFullscreen();
}
static bool verifyCustomHandlerURL(const KURL& baseURL, const String& url, ExceptionState& exceptionState)
{
    // The specification requires that it is a SyntaxError if the "%s" token is
    // not present.
    static const char token[] = "%s";
    int index = url.find(token);
    if (-1 == index) {
        exceptionState.throwDOMException(SyntaxError, "The url provided ('" + url + "') does not contain '%s'.");
        return false;
    }

    // It is also a SyntaxError if the custom handler URL, as created by removing
    // the "%s" token and prepending the base url, does not resolve.
    String newURL = url;
    newURL.remove(index, WTF_ARRAY_LENGTH(token) - 1);

    KURL kurl(baseURL, newURL);

    if (kurl.isEmpty() || !kurl.isValid()) {
        exceptionState.throwDOMException(SyntaxError, "The custom handler URL created by removing '%s' and prepending '" + baseURL.string() + "' is invalid.");
        return false;
    }

    return true;
}
示例#5
0
TEST(KURLTest, Ref)
{
    KURL kurl(ParsedURLString, "http://foo/bar#baz");

    // Basic ref setting.
    KURL cur(ParsedURLString, "http://foo/bar");
    cur.setFragmentIdentifier("asdf");
    EXPECT_STREQ("http://foo/bar#asdf", cur.string().utf8().data());
    cur = kurl;
    cur.setFragmentIdentifier("asdf");
    EXPECT_STREQ("http://foo/bar#asdf", cur.string().utf8().data());

    // Setting a ref to the empty string will set it to "#".
    cur = KURL(ParsedURLString, "http://foo/bar");
    cur.setFragmentIdentifier("");
    EXPECT_STREQ("http://foo/bar#", cur.string().utf8().data());
    cur = kurl;
    cur.setFragmentIdentifier("");
    EXPECT_STREQ("http://foo/bar#", cur.string().utf8().data());

    // Setting the ref to the null string will clear it altogether.
    cur = KURL(ParsedURLString, "http://foo/bar");
    cur.setFragmentIdentifier(String());
    EXPECT_STREQ("http://foo/bar", cur.string().utf8().data());
    cur = kurl;
    cur.setFragmentIdentifier(String());
    EXPECT_STREQ("http://foo/bar", cur.string().utf8().data());
}
示例#6
0
// Test that setting the query to different things works. Thq query is handled
// a littler differently than some of the other components.
TEST(KURLTest, Query)
{
    const char initial[] = "http://www.google.com/search?q=awesome";
    KURL kurl(ParsedURLString, initial);

    // Clear by setting a null string.
    String nullString;
    EXPECT_TRUE(nullString.isNull());
    kurl.setQuery(nullString);
    EXPECT_STREQ("http://www.google.com/search", kurl.string().utf8().data());

    // Clear by setting an empty string.
    kurl = KURL(ParsedURLString, initial);
    String emptyString("");
    EXPECT_FALSE(emptyString.isNull());
    kurl.setQuery(emptyString);
    EXPECT_STREQ("http://www.google.com/search?", kurl.string().utf8().data());

    // Set with something that begins in a question mark.
    const char question[] = "?foo=bar";
    kurl.setQuery(question);
    EXPECT_STREQ("http://www.google.com/search?foo=bar",
                 kurl.string().utf8().data());

    // Set with something that doesn't begin in a question mark.
    const char query[] = "foo=bar";
    kurl.setQuery(query);
    EXPECT_STREQ("http://www.google.com/search?foo=bar",
                 kurl.string().utf8().data());
}
// MediaPlayer -------------------------------------------------
void WebMediaPlayerClientImpl::load(WebMediaPlayer::LoadType loadType, const WTF::String& url, WebMediaPlayer::CORSMode corsMode)
{
    ASSERT(!m_webMediaPlayer);

    // FIXME: Remove this cast
    LocalFrame* frame = mediaElement().document().frame();

    WebURL poster = m_client->mediaPlayerPosterURL();

    KURL kurl(ParsedURLString, url);
    m_webMediaPlayer = createWebMediaPlayer(this, kurl, frame);
    if (!m_webMediaPlayer)
        return;

#if ENABLE(WEB_AUDIO)
    // Make sure if we create/re-create the WebMediaPlayer that we update our wrapper.
    m_audioSourceProvider.wrap(m_webMediaPlayer->audioSourceProvider());
#endif

    m_webMediaPlayer->setVolume(mediaElement().playerVolume());

    m_webMediaPlayer->setPoster(poster);

#if OS(ANDROID)
    m_usePaintOnAndroid = (loadType != WebMediaPlayer::LoadTypeMediaStream);
#endif

    // Tell WebMediaPlayer about any connected CDM (may be null).
    m_webMediaPlayer->setContentDecryptionModule(HTMLMediaElementEncryptedMedia::contentDecryptionModule(mediaElement()));
    m_webMediaPlayer->load(loadType, kurl, corsMode);
}
jint WebCoreResourceLoader::CreateResponse(JNIEnv* env, jobject obj, jstring url, jint statusCode,
                                                    jstring statusText, jstring mimeType, jlong expectedLength,
                                                    jstring encoding)
{
#ifdef ANDROID_INSTRUMENT
    TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
#endif
    LOG_ASSERT(url, "Must have a url in the response!");
    WebCore::KURL kurl(WebCore::ParsedURLString, to_string(env, url));
    WebCore::String encodingStr;
    WebCore::String mimeTypeStr;
    if (mimeType) {
        mimeTypeStr = to_string(env, mimeType);
        LOGV("Response setMIMEType: %s", mimeTypeStr.latin1().data());
    }
    if (encoding) {
        encodingStr = to_string(env, encoding);
        LOGV("Response setTextEncodingName: %s", encodingStr.latin1().data());
    }
    WebCore::ResourceResponse* response = new WebCore::ResourceResponse(
            kurl, mimeTypeStr, (long long)expectedLength,
            encodingStr, WebCore::String());
    response->setHTTPStatusCode(statusCode);
    if (statusText) {
        WebCore::String status = to_string(env, statusText);
        response->setHTTPStatusText(status);
        LOGV("Response setStatusText: %s", status.latin1().data());
    }
    return (int)response;
}
static bool verifyCustomHandlerURL(const String& baseURL, const String& url, ExceptionCode& ec)
{
    // The specification requires that it is a SYNTAX_ERR if the "%s" token is
    // not present.
    static const char token[] = "%s";
    int index = url.find(token);
    if (-1 == index) {
        ec = SYNTAX_ERR;
        return false;
    }

    // It is also a SYNTAX_ERR if the custom handler URL, as created by removing
    // the "%s" token and prepending the base url, does not resolve.
    String newURL = url;
    newURL.remove(index, WTF_ARRAY_LENGTH(token) - 1);

    URL base(ParsedURLString, baseURL);
    URL kurl(base, newURL);

    if (kurl.isEmpty() || !kurl.isValid()) {
        ec = SYNTAX_ERR;
        return false;
    }

    return true;
}
示例#10
0
bool CSSCursorImageValue::isSVGCursor() const
{
    if (is<CSSImageValue>(m_imageValue.get())) {
        URL kurl(ParsedURLString, downcast<CSSImageValue>(m_imageValue.get()).url());
        return kurl.hasFragmentIdentifier();
    }
    return false;
}
示例#11
0
bool CSSCursorImageValue::isSVGCursor() const
{
    if (m_imageValue.get().isImageValue()) {
        URL kurl(ParsedURLString, toCSSImageValue(m_imageValue.get()).url());
        return kurl.hasFragmentIdentifier();
    }
    return false;
}
示例#12
0
bool CSSCursorImageValue::hasFragmentInURL() const {
  if (m_imageValue->isImageValue()) {
    CSSImageValue* imageValue = toCSSImageValue(m_imageValue.get());
    KURL kurl(ParsedURLString, imageValue->url());
    return kurl.hasFragmentIdentifier();
  }
  return false;
}
bool CSSCursorImageValue::isSVGCursor() const
{
    if (m_imageValue->isImageValue()) {
        RefPtr<CSSImageValue> imageValue = static_cast<CSSImageValue*>(m_imageValue.get());
        KURL kurl(ParsedURLString, imageValue->url());
        return kurl.hasFragmentIdentifier();
    }
    return false;
}
示例#14
0
TEST(KURLTest, Path)
{
    const char initial[] = "http://www.google.com/path/foo";
    KURL kurl(ParsedURLString, initial);

    // Clear by setting a null string.
    String nullString;
    EXPECT_TRUE(nullString.isNull());
    kurl.setPath(nullString);
    EXPECT_STREQ("http://www.google.com/", kurl.string().utf8().data());
}
示例#15
0
cairo_surface_t* ewk_settings_icon_database_icon_surface_get(const char* url)
{
    EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0);

    WebCore::URL kurl(WebCore::URL(), WTF::String::fromUTF8(url));
    RefPtr<cairo_surface_t> icon = WebCore::iconDatabase().synchronousNativeIconForPageURL(kurl.string(), WebCore::IntSize(16, 16));
    if (!icon)
        ERR("no icon for url %s", url);

    return icon.get();
}
示例#16
0
WebCore::ProtectionSpace getProtectionSpace(const char* url, WebString& realm, WebString& scheme)
{
    WebCore::ProtectionSpaceAuthenticationScheme protectionSpaceScheme = WebCore::ProtectionSpaceAuthenticationSchemeDefault;
    if (equalIgnoringCase(scheme, "ntlm"))
        protectionSpaceScheme = WebCore::ProtectionSpaceAuthenticationSchemeNTLM;
    else if (equalIgnoringCase(scheme, "basic"))
        protectionSpaceScheme = WebCore::ProtectionSpaceAuthenticationSchemeHTTPBasic;
    else if (equalIgnoringCase(scheme, "digest"))
        protectionSpaceScheme = WebCore::ProtectionSpaceAuthenticationSchemeHTTPDigest;
    WebCore::KURL kurl(WebCore::KURL(), url);
    return WebCore::ProtectionSpace(kurl.host(), kurl.port(), realm.equalIgnoringCase("ftp") ?
            WebCore::ProtectionSpaceServerFTP : WebCore::ProtectionSpaceServerHTTP, realm, protectionSpaceScheme);
}
示例#17
0
/**
 * Query icon for given URL, returning associated cairo surface.
 *
 * @note in order to have this working, one must open icon database
 *       with ewk_settings_icon_database_path_set().
 *
 * @param url which url to query icon.
 *
 * @return cairo surface if any, or NULL on failure.
 */
cairo_surface_t* ewk_settings_icon_database_icon_surface_get(const char *url)
{
    EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0);

    WebCore::KURL kurl(WebCore::KURL(), WebCore::String::fromUTF8(url));
    WebCore::Image *icon = WebCore::iconDatabase()->iconForPageURL(kurl.string(), WebCore::IntSize(16, 16));

    if (!icon) {
        ERR("no icon for url %s", url);
        return 0;
    }

    return icon->nativeImageForCurrentFrame();
}
示例#18
0
// Test the cases where we should be the same as WebKit's old KURL.
TEST(KURLTest, SameGetters)
{
    struct GetterCase {
        const char* url;
        const char* protocol;
        const char* host;
        int port;
        const char* user;
        const char* pass;
        const char* lastPathComponent;
        const char* query;
        const char* ref;
        bool hasRef;
    } cases[] = {
        {"http://www.google.com/foo/blah?bar=baz#ref", "http", "www.google.com", 0, "", 0, "blah", "bar=baz", "ref", true},
        {"http://foo.com:1234/foo/bar/", "http", "foo.com", 1234, "", 0, "bar", 0, 0, false},
        {"http://www.google.com?#", "http", "www.google.com", 0, "", 0, 0, "", "", true},
        {"https://*****:*****@google.com:23#foo", "https", "google.com", 23, "me", "pass", 0, 0, "foo", true},
        {"javascript:hello!//world", "javascript", "", 0, "", 0, "world", 0, 0, false},
    };

    for (size_t i = 0; i < arraysize(cases); i++) {
        // UTF-8
        KURL kurl(ParsedURLString, cases[i].url);

        EXPECT_EQ(cases[i].protocol, kurl.protocol());
        EXPECT_EQ(cases[i].host, kurl.host());
        EXPECT_EQ(cases[i].port, kurl.port());
        EXPECT_EQ(cases[i].user, kurl.user());
        EXPECT_EQ(cases[i].pass, kurl.pass());
        EXPECT_EQ(cases[i].lastPathComponent, kurl.lastPathComponent());
        EXPECT_EQ(cases[i].query, kurl.query());
        EXPECT_EQ(cases[i].ref, kurl.fragmentIdentifier());
        EXPECT_EQ(cases[i].hasRef, kurl.hasFragmentIdentifier());

        // UTF-16
        String utf16(cases[i].url);
        kurl = KURL(ParsedURLString, utf16);

        EXPECT_EQ(cases[i].protocol, kurl.protocol());
        EXPECT_EQ(cases[i].host, kurl.host());
        EXPECT_EQ(cases[i].port, kurl.port());
        EXPECT_EQ(cases[i].user, kurl.user());
        EXPECT_EQ(cases[i].pass, kurl.pass());
        EXPECT_EQ(cases[i].lastPathComponent, kurl.lastPathComponent());
        EXPECT_EQ(cases[i].query, kurl.query());
        EXPECT_EQ(cases[i].ref, kurl.fragmentIdentifier());
        EXPECT_EQ(cases[i].hasRef, kurl.hasFragmentIdentifier());
    }
}
示例#19
0
String SVGURIReference::fragmentIdentifierFromIRIString(const String& url, Document& document)
{
    size_t start = url.find('#');
    if (start == notFound)
        return emptyString();

    KURL base = start ? KURL(document.baseURI(), url.substring(0, start)) : document.baseURI();
    String fragmentIdentifier = url.substring(start);
    KURL kurl(base, fragmentIdentifier);
    if (equalIgnoringFragmentIdentifier(kurl, document.url()))
        return fragmentIdentifier.substring(1);

    // The url doesn't have any fragment identifier.
    return emptyString();
}
示例#20
0
Evas_Object* ewk_settings_icon_database_icon_object_get(const char* url, Evas* canvas)
{
    EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0);
    EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);

    WebCore::URL kurl(WebCore::URL(), WTF::String::fromUTF8(url));
    RefPtr<cairo_surface_t> surface = WebCore::iconDatabase().synchronousNativeIconForPageURL(kurl.string(), WebCore::IntSize(16, 16));

    if (!surface) {
        ERR("no icon for url %s", url);
        return 0;
    }

    return surface ? WebCore::evasObjectFromCairoImageSurface(canvas, surface.get()).leakRef() : 0;
}
示例#21
0
Evas_Object* ewk_settings_icon_database_icon_object_get(const char* url, Evas* canvas)
{
    EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0);
    EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);

    WebCore::KURL kurl(WebCore::KURL(), WTF::String::fromUTF8(url));
    WebCore::Image* icon = WebCore::iconDatabase().synchronousIconForPageURL(kurl.string(), WebCore::IntSize(16, 16));

    if (!icon) {
        ERR("no icon for url %s", url);
        return 0;
    }

    WebCore::NativeImageCairo* nativeImage = icon->nativeImageForCurrentFrame();
    return nativeImage ? ewk_util_image_from_cairo_surface_add(canvas, nativeImage->surface()) : 0;
}
示例#22
0
/**
 * Create Evas_Object of type image representing the given URL.
 *
 * This is an utility function that creates an Evas_Object of type
 * image set to have fill always match object size
 * (evas_object_image_filled_add()), saving some code to use it from Evas.
 *
 * @note in order to have this working, one must open icon database
 *       with ewk_settings_icon_database_path_set().
 *
 * @param url which url to query icon.
 * @param canvas evas instance where to add resulting object.
 *
 * @return newly allocated Evas_Object instance or @c NULL on
 *         errors. Delete the object with evas_object_del().
 */
Evas_Object* ewk_settings_icon_database_icon_object_add(const char* url, Evas* canvas)
{
    EINA_SAFETY_ON_NULL_RETURN_VAL(url, 0);
    EINA_SAFETY_ON_NULL_RETURN_VAL(canvas, 0);

    WebCore::KURL kurl(WebCore::KURL(), WebCore::String::fromUTF8(url));
    WebCore::Image* icon = WebCore::iconDatabase()->iconForPageURL(kurl.string(), WebCore::IntSize(16, 16));
    cairo_surface_t* surface;

    if (!icon) {
        ERR("no icon for url %s", url);
        return 0;
    }

    surface = icon->nativeImageForCurrentFrame();
    return ewk_util_image_from_cairo_surface_add(canvas, surface);
}
示例#23
0
void MediaPlayerPrivateEA::load(const String& url)
{
    if (!mpEAWebKitView)
        mpEAWebKitView = GetEAWebKitMediaView(mpWebCorePlayer);

    // Note: We get the autoplay and loop flags from the element directly.
    HTMLMediaElement* element = static_cast<HTMLMediaElement*>(mpWebCorePlayer->mediaPlayerClient());
    mIsLooping = element->loop();
   
    MediaUpdateInfo& info = GetMediaUpdateInfo();  
    info.mIsLooping = mIsLooping; 
	WebCore::KURL kurl(WebCore::KURL(), url);
	String escapedUrl = kurl.protocolIsInHTTPFamily() ? url : decodeURLEscapeSequences(url);

    GetFixedString(info.mURI)->assign(escapedUrl.characters(), escapedUrl.length());
    ClientUpdate(MediaUpdateInfo::kLoad);
    
    // Set info up to play
    setMuted(mpWebCorePlayer->muted());
    setVolume(mpWebCorePlayer->volume());
    
    if(mNetworkState != MediaPlayer::Loading)
    {
        mNetworkState = MediaPlayer::Loading;
        mpWebCorePlayer->networkStateChanged();
    }
    
    if(mReadyState != MediaPlayer::HaveNothing)
    {
       mReadyState = MediaPlayer::HaveNothing; 
       mpWebCorePlayer->readyStateChanged(); 
    }
    
    bool autoPlay = element->autoplay();
    if(autoPlay)
        mpWebCorePlayer->play();            // This just calls our play.

    ClientUpdateStates();                   // This will update the pause/play state right away.

    // Set up an update timer to control the repaint and playback.
    if (mUpdateTimer.isActive())
        mUpdateTimer.stop();
    const double kUpdateTime = 1.0/60.0;      // We want to update at 60hz so we keep up with the render calls. 
    mUpdateTimer.startRepeating(kUpdateTime);
}
示例#24
0
TEST(KURLTest, UserPass)
{
    const char* src = "http://*****:*****@google.com/";
    KURL kurl(ParsedURLString, src);

    // Clear just the username.
    kurl.setUser("");
    EXPECT_EQ("http://:[email protected]/", kurl.string());

    // Clear just the password.
    kurl = KURL(ParsedURLString, src);
    kurl.setPass("");
    EXPECT_EQ("http://[email protected]/", kurl.string());

    // Now clear both.
    kurl.setUser("");
    EXPECT_EQ("http://google.com/", kurl.string());
}
static bool verifyCustomHandlerURL(const URL& baseURL, const String& url)
{
    // The specification requires that it is a SyntaxError if the "%s" token is
    // not present.
    static const char token[] = "%s";
    int index = url.find(token);
    if (-1 == index)
        return false;

    // It is also a SyntaxError if the custom handler URL, as created by removing
    // the "%s" token and prepending the base url, does not resolve.
    String newURL = url;
    newURL.remove(index, WTF_ARRAY_LENGTH(token) - 1);

    URL kurl(baseURL, newURL);

    if (kurl.isEmpty() || !kurl.isValid())
        return false;

    return true;
}
示例#26
0
const string WebResponse::resolveMimeType(const string& url, const string& old_mime)
{
    // Use "text/html" as a default (matching the behaviour of the Apache
    // HTTP stack -- see guessMimeType() in LoadListener.java).
    string mimeType = old_mime.length() ? old_mime : "text/html";
    // Try to guess a better MIME type from the URL. We call
    // getMIMETypeForExtension rather than getMIMETypeForPath because the
    // latter defaults to "application/octet-stream" on failure.
    WebCore::KURL kurl(WebCore::ParsedURLString, url.c_str());
    WTF::String path = kurl.path();
    size_t extensionPos = path.reverseFind('.');
    if (extensionPos != WTF::notFound) {
        // We found a file extension.
        path.remove(0, extensionPos + 1);
        // TODO: Should use content-disposition instead of url if it is there
        WTF::String mime = WebCore::MIMETypeRegistry::getMIMETypeForExtension(path);
        if (!mime.isEmpty()) {
            // Great, we found a MIME type.
            mimeType = std::string(mime.utf8().data(), mime.length());
        }
    }
    return mimeType;
}
示例#27
0
bool KCookieJar::parseURL(const QString &_url,
                          QString &_fqdn,
                          QString &_path)
{
    KURL kurl(_url);
    if (!kurl.isValid())
       return false;

    _fqdn = kurl.host().lower();
    if (kurl.port())
    {
       if (((kurl.protocol() == L1("http")) && (kurl.port() != 80)) ||
           ((kurl.protocol() == L1("https")) && (kurl.port() != 443)))
       {
          _fqdn = L1("%1:%2").arg(kurl.port()).arg(_fqdn);
       }
    }

    // Cookie spoofing protection.  Since there is no way a path separator
    // or escape encoded character is allowed in the hostname according
    // to RFC 2396, reject attempts to include such things there!
    if(_fqdn.find('/') > -1 || _fqdn.find('%') > -1)
    {
        return false;  // deny everything!!
    }

    _path = kurl.path();
    if (_path.isEmpty())
       _path = L1("/");

    QRegExp exp(L1("[\\\\/]\\.\\.[\\\\/]"));
    // Weird path, cookie stealing attempt?
    if (exp.search(_path) != -1)
       return false; // Deny everything!!

    return true;
}
示例#28
0
// Test a few cases where we're different just to make sure we give reasonable
// output.
TEST(KURLTest, DISABLED_DifferentGetters)
{
    ComponentCase cases[] = {
        // url                                    protocol      host        port  user  pass             lastPath  query      ref

        // Old WebKit allows references and queries in what we call "path" URLs
        // like javascript, so the path here will only consist of "hello!".
        {"javascript:hello!?#/\\world",           "javascript", "",         0,    "",   0,               "world",  0,         0},

        // Old WebKit doesn't handle "parameters" in paths, so will
        // disagree with us about where the path is for this URL.
        {"http://a.com/hello;world",              "http",       "a.com",    0,    "",   0,               "hello",  0,         0},

        // WebKit doesn't like UTF-8 or UTF-16 input.
        {"http://\xe4\xbd\xa0\xe5\xa5\xbd\xe4\xbd\xa0\xe5\xa5\xbd/", "http", "xn--6qqa088eba", 0, "", 0, 0,        0,         0},

        // WebKit %-escapes non-ASCII characters in reference, but we don't.
        {"http://www.google.com/foo/blah?bar=baz#\xce\xb1\xce\xb2", "http", "www.google.com", 0, "", 0,  "blah", "bar=baz", "\xce\xb1\xce\xb2"},
    };

    for (size_t i = 0; i < arraysize(cases); i++) {
        KURL kurl(ParsedURLString, cases[i].url);

        EXPECT_EQ(cases[i].protocol, kurl.protocol());
        EXPECT_EQ(cases[i].host, kurl.host());
        EXPECT_EQ(cases[i].port, kurl.port());
        EXPECT_EQ(cases[i].user, kurl.user());
        EXPECT_EQ(cases[i].pass, kurl.pass());
        EXPECT_EQ(cases[i].lastPath, kurl.lastPathComponent());
        EXPECT_EQ(cases[i].query, kurl.query());
        // Want to compare UCS-16 refs (or to null).
        if (cases[i].ref)
            EXPECT_EQ(String::fromUTF8(cases[i].ref), kurl.fragmentIdentifier());
        else
            EXPECT_TRUE(kurl.fragmentIdentifier().isNull());
    }
}
示例#29
0
TEST(KURLTest, strippedForUseAsReferrer)
{
    struct ReferrerCase {
        const char* input;
        const char* output;
    } referrerCases[] = {
        {"data:text/html;charset=utf-8,<html></html>", ""},
        {"javascript:void(0);", ""},
        {"about:config", ""},
        {"https://www.google.com/", "https://www.google.com/"},
        {"http://[email protected]:8888/", "http://news.google.com:8888/"},
        {"http://:[email protected]:8888/foo", "http://news.google.com:8888/foo"},
        {"http://*****:*****@news.google.com:8888/", "http://news.google.com:8888/"},
        {"https://www.google.com/a?f#b", "https://www.google.com/a?f"},
        {"file:///tmp/test.html", ""},
        {"https://www.google.com/#", "https://www.google.com/"},
    };

    for (size_t i = 0; i < arraysize(referrerCases); i++) {
        KURL kurl(ParsedURLString, referrerCases[i].input);
        String referrer = kurl.strippedForUseAsReferrer();
        EXPECT_STREQ(referrerCases[i].output, referrer.utf8().data());
    }
}
static inline bool isSVGCursorIdentifier(const String& url)
{
    KURL kurl(ParsedURLString, url);
    return kurl.hasFragmentIdentifier();
}