bool CVFSEntry::GetDirectory(const CStdString& strPath, CFileItemList& items) { if (!Initialized()) return false; CURL url(strPath); VFSCallbacks callbacks; callbacks.ctx = this; callbacks.GetKeyboardInput = CVFSEntryIDirectoryWrapper::DoGetKeyboardInput; callbacks.SetErrorDialog = CVFSEntryIDirectoryWrapper::DoSetErrorDialog; callbacks.RequireAuthentication = CVFSEntryIDirectoryWrapper::DoRequireAuthentication; VFSDirEntry* entries; int num_entries; CVFSURLWrapper url2(url); void* ctx = m_pStruct->GetDirectory(&url2.url, &entries, &num_entries, &callbacks); if (ctx) { VFSDirEntriesToCFileItemList(num_entries, entries, items); m_pStruct->FreeDirectory(ctx); return true; } return false; }
int TestURLChars(void) { // Number of tests int errors = 2; CString urlString("http://" MARLIN_HOST "/Marlin Test all/URL?first=abc&second=באהגיטכךםלןמףעצפתש���חסץד"); CString mustBeUrl("http://" MARLIN_HOST "/Marlin%20Test%20all/URL?first=abc&second=%C3%A1%C3%A0%C3%A4%C3%A2%C3%A9%C3%A8%C3%AB%C3%AA%C3%AD%C3%AC%C3%AF%C3%AE%C3%B3%C3%B2%C3%B6%C3%B4%C3%BA%C3%B9%C3%BC%C3%BB%C3%BD%C3%BF%C3%A7%C3%B1%C3%B5%C3%A3"); CrackedURL url1(urlString); CString encoded = url1.URL(); // Test if success if(encoded == mustBeUrl) { --errors; } // Encoding of higher order UTF-8 like the euro signs urlString = "http://" MARLIN_HOST "/Een%20Twee%20drie?een=waarde=%3Crequest%3E%3Cpage%3Eklantenkaart%3C%2Fpage%3E%3Crequesttype%3Econtactmemoaanmaken%3C%2Frequesttype%3E%3Ccallback%3EdesktopCallback%3C%2Fcallback%3E%3Cparameters%3E%3Cparameter%3E%3Cname%3Econtactmemogegevens%3C%2Fname%3E%3Cvalue%3E%7B%22contact_id%22:151714,%22eerste_contact_id%22:151714,%22werknemer_id%22:2942,%22werknemer_naam%22:%22N.N.+Bhoera%22,%22beheerorgnaam%22:%22Edwin%22,%22richting%22:%22uit%22,%22onderwerp%22:%22H%C3%AF%C3%ABr+st%C3%A4%C3%A4n+%E2%82%AC+test%22%7D%3C%2Fvalue%3E%3C%2Fparameter%3E%3C%2Fparameters%3E%3C%2Frequest%3E"; CrackedURL url2(urlString); encoded = url2.URL(); // Test if success if(urlString == encoded) { --errors; } // SUMMARY OF THE TEST // --- "---------------------------------------------- - ------ printf("Testing URL %% encoding and Unicode chars : %s\n",errors ? "ERROR" : "OK"); return errors; }
TEST_F(TestURIUtils, IsInternetStream) { CURL url1("http://path/to/file"); CURL url2("https://path/to/file"); EXPECT_TRUE(URIUtils::IsInternetStream(url1)); EXPECT_TRUE(URIUtils::IsInternetStream(url2)); }
void* CVFSEntry::Open(const CURL& url) { if (!Initialized()) return NULL; CVFSURLWrapper url2(url); return m_pStruct->Open(&url2.url); }
void* CVFSEntry::OpenForWrite(const CURL& url, bool bOverWrite) { if (!Initialized()) return NULL; CVFSURLWrapper url2(url); return m_pStruct->OpenForWrite(&url2.url, bOverWrite); }
bool CVFSEntry::Exists(const CURL& url) { if (!Initialized()) return false; CVFSURLWrapper url2(url); return m_pStruct->Exists(&url2.url); }
int CVFSEntry::Stat(const CURL& url, struct __stat64* buffer) { if (!Initialized()) return -1; CVFSURLWrapper url2(url); return m_pStruct->Stat(&url2.url, buffer); }
bool CVFSEntry::DirectoryExists(const CURL& url) { if (!m_struct.toAddon.directory_exists) return false; CVFSURLWrapper url2(url); return m_struct.toAddon.directory_exists(&m_struct, &url2.url); }
bool CVFSEntry::CreateDirectory(const CURL& url) { if (!m_struct.toAddon.create_directory) return false; CVFSURLWrapper url2(url); return m_struct.toAddon.create_directory(&m_struct, &url2.url); }
bool CVFSEntry::Delete(const CURL& url) { if (!m_struct.toAddon.delete_it) return false; CVFSURLWrapper url2(url); return m_struct.toAddon.delete_it(&m_struct, &url2.url); }
int CVFSEntry::Stat(const CURL& url, struct __stat64* buffer) { if (!m_struct.toAddon.stat) return -1; CVFSURLWrapper url2(url); return m_struct.toAddon.stat(&m_struct, &url2.url, buffer); }
void* CVFSEntry::OpenForWrite(const CURL& url, bool bOverWrite) { if (!m_struct.toAddon.open_for_write) return nullptr; CVFSURLWrapper url2(url); return m_struct.toAddon.open_for_write(&m_struct, &url2.url, bOverWrite); }
void* CVFSEntry::Open(const CURL& url) { if (!m_struct.toAddon.open) return nullptr; CVFSURLWrapper url2(url); return m_struct.toAddon.open(&m_struct, &url2.url); }
bool CVFSEntry::CreateDirectory(const CURL& url) { if (!Initialized()) return false; CVFSURLWrapper url2(url); return m_pStruct->CreateDirectory(&url2.url); }
QString Utils::fileNameForUrl(const QString &url_p) { QString url2(url_p); url2 = url2.replace("/", "_").replace(":", "_"); if(url2.length() > 255) url2 = url2.left(200) + QString::number(Akregator::Utils::calcHash(url2), 16); return url2; }
TEST(WebKit2, DISABLED_DOMWindowExtensionBasic) { WKRetainPtr<WKPageGroupRef> pageGroup(AdoptWK, WKPageGroupCreateWithIdentifier(WKStringCreateWithUTF8CString("DOMWindowExtensionBasicPageGroup"))); WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("DOMWindowExtensionBasic", pageGroup.get())); WKContextInjectedBundleClientV0 injectedBundleClient; memset(&injectedBundleClient, 0, sizeof(injectedBundleClient)); injectedBundleClient.base.version = 0; injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle; WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient.base); // The default cache model has a capacity of 0, so it is necessary to switch to a cache // model that actually allows for a page cache. WKContextSetCacheModel(context.get(), kWKCacheModelDocumentBrowser); PlatformWebView webView(context.get(), pageGroup.get()); // Make sure the extensions for each frame are installed in each world. WKRetainPtr<WKURLRef> url1(AdoptWK, Util::createURLForResource("simple-iframe", "html")); WKPageLoadURL(webView.page(), url1.get()); Util::run(&finished); finished = false; // Make sure those first 4 extensions are disconnected, and 2 new ones are installed. WKRetainPtr<WKURLRef> url2(AdoptWK, Util::createURLForResource("simple", "html")); WKPageLoadURL(webView.page(), url2.get()); Util::run(&finished); finished = false; // Make sure those two are disconnected, and the first four are reconnected. WKPageGoBack(webView.page()); Util::run(&finished); finished = false; // Make sure the 2 disconnected extensions in the page cache and the 4 active extensions are all removed. WKPageClose(webView.page()); Util::run(&finished); const size_t expectedSize = sizeof(expectedMessages) / sizeof(const char*); EXPECT_EQ(expectedSize, messages.size()); if (messages.size() != expectedSize) return; for (size_t i = 0; i < messages.size(); ++i) EXPECT_WK_STREQ(expectedMessages[i], messages[i].get()); }
bool CAsyncFileCopy::Copy(const CStdString &from, const CStdString &to, const CStdString &heading) { // reset the variables to their appropriate states m_from = from; m_to = to; m_cancelled = false; m_succeeded = false; m_percent = 0; m_speed = 0; m_running = true; CStdString fromStripped, toStripped; CURL url1(from); url1.GetURLWithoutUserDetails(fromStripped); CURL url2(to); url2.GetURLWithoutUserDetails(toStripped); // create our thread, which starts the file copy operation Create(); CGUIDialogProgress *dlg = (CGUIDialogProgress *)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS); DWORD time = timeGetTime(); while (m_running) { m_event.WaitMSec(1000 / 30); if (!m_running) break; // start the dialog up as needed if (dlg && !dlg->IsDialogRunning() && timeGetTime() > time + 500) // wait 0.5 seconds before starting dialog { dlg->SetHeading(heading); dlg->SetLine(0, fromStripped); dlg->SetLine(1, toStripped); dlg->SetPercentage(0); dlg->StartModal(); } // and update the dialog as we go if (dlg && dlg->IsDialogRunning()) { CStdString speedString; speedString.Format("%2.2f KB/s", m_speed / 1024); dlg->SetHeading(heading); dlg->SetLine(0, fromStripped); dlg->SetLine(1, toStripped); dlg->SetLine(2, speedString); dlg->SetPercentage(m_percent); dlg->Progress(); m_cancelled = dlg->IsCanceled(); } } if (dlg) dlg->Close(); return !m_cancelled && m_succeeded; }
TEST(WebKit2, DISABLED_DOMWindowExtensionNoCache) { WKRetainPtr<WKPageGroupRef> pageGroup(AdoptWK, WKPageGroupCreateWithIdentifier(WKStringCreateWithUTF8CString("DOMWindowExtensionNoCachePageGroup"))); WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextForInjectedBundleTest("DOMWindowExtensionNoCache", pageGroup.get())); WKContextInjectedBundleClientV1 injectedBundleClient; memset(&injectedBundleClient, 0, sizeof(injectedBundleClient)); injectedBundleClient.base.version = 1; injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle; WKContextSetInjectedBundleClient(context.get(), &injectedBundleClient.base); // Disable the page cache. WKContextSetCacheModel(context.get(), kWKCacheModelDocumentViewer); PlatformWebView webView(context.get(), pageGroup.get()); // Make sure the extensions for each frame are installed in each world. WKRetainPtr<WKURLRef> url1(AdoptWK, Util::createURLForResource("simple-iframe", "html")); WKPageLoadURL(webView.page(), url1.get()); Util::run(&finished); finished = false; // Make sure those first 4 extensions are destroyed, and 2 new ones are installed. WKRetainPtr<WKURLRef> url2(AdoptWK, Util::createURLForResource("simple", "html")); WKPageLoadURL(webView.page(), url2.get()); Util::run(&finished); finished = false; // Make sure those 2 are destroyed, and the first 4 are recreated. WKPageGoBack(webView.page()); Util::run(&finished); finished = false; WKPageClose(webView.page()); Util::run(&finished); const size_t expectedSize = sizeof(expectedMessages) / sizeof(const char*); EXPECT_EQ(expectedSize, messages.size()); if (messages.size() != expectedSize) return; for (size_t i = 0; i < messages.size(); ++i) EXPECT_WK_STREQ(expectedMessages[i], messages[i].get()); }
TEST(KURLTest, ProtocolIs) { KURL url1(ParsedURLString, "foo://bar"); EXPECT_TRUE(url1.protocolIs("foo")); EXPECT_FALSE(url1.protocolIs("foo-bar")); KURL url2(ParsedURLString, "foo-bar:"); EXPECT_TRUE(url2.protocolIs("foo-bar")); EXPECT_FALSE(url2.protocolIs("foo")); KURL invalidUTF8(ParsedURLString, "http://a@9%aa%:"); EXPECT_FALSE(invalidUTF8.protocolIs("http")); EXPECT_TRUE(invalidUTF8.protocolIs("")); }
bool CAsyncFileCopy::Copy(const std::string &from, const std::string &to, const std::string &heading) { // reset the variables to their appropriate states m_from = from; m_to = to; m_cancelled = false; m_succeeded = false; m_percent = 0; m_speed = 0; m_running = true; CURL url1(from); CURL url2(to); // create our thread, which starts the file copy operation Create(); CGUIDialogProgress *dlg = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); unsigned int time = XbmcThreads::SystemClockMillis(); while (m_running) { m_event.WaitMSec(1000 / 30); if (!m_running) break; // start the dialog up as needed if (dlg && !dlg->IsDialogRunning() && (XbmcThreads::SystemClockMillis() - time) > 500) // wait 0.5 seconds before starting dialog { dlg->SetHeading(CVariant{heading}); dlg->SetLine(0, CVariant{url1.GetWithoutUserDetails()}); dlg->SetLine(1, CVariant{url2.GetWithoutUserDetails()}); dlg->SetPercentage(0); dlg->StartModal(); } // and update the dialog as we go if (dlg && dlg->IsDialogRunning()) { dlg->SetHeading(CVariant{heading}); dlg->SetLine(0, CVariant{url1.Get()}); dlg->SetLine(1, CVariant{url2.Get()}); dlg->SetLine(2, CVariant{ StringUtils::Format("%2.2f KB/s", m_speed / 1024) }); dlg->SetPercentage(m_percent); dlg->Progress(); m_cancelled = dlg->IsCanceled(); } } if (dlg) dlg->Close(); return !m_cancelled && m_succeeded; }
bool WatchDog::IsPathAvailable(const CStdString &pathToCheck, bool bDefault) { #ifdef WATCHDOG_DONT_TEST_PATH return true; #else CStdString strPath = _P(pathToCheck); CFileItem item; item.m_strPath = strPath; if (item.IsApp()) return true; if (item.IsInternetStream()) return g_application.IsConnectedToNet(); CSingleLock lock(m_lock); CURI url1 (strPath); CStdString strUrl1; strUrl1 = url1.Get(); strUrl1 = BOXEE::BXUtils::RemoveSMBCredentials(strUrl1); strUrl1.ToLower(); CUtil::RemoveSlashAtEnd(strUrl1); for (std::map<CStdString, PathStatus>::iterator iter=m_mapPaths.begin(); iter != m_mapPaths.end(); iter++) { CURI url2(iter->first); CStdString strUrl2; strUrl2 = url2.Get(); strUrl2 = BOXEE::BXUtils::RemoveSMBCredentials(strUrl2); strUrl2.ToLower(); CUtil::RemoveSlashAtEnd(strUrl2); if(strUrl1.Find(strUrl2) >= 0) { if (iter->second == WD_UNKNOWN) { return bDefault; } return (iter->second == WD_AVAILABLE); } } return bDefault; // we dont know... #endif }
bool CAddonCallbacksAddon::AuthenticateURL(const void* addonData, VFSURL* url) { CAddonCallbacks* helper = (CAddonCallbacks*) addonData; if (!helper) return NULL; CURL url2(url->url); bool result = CPasswordManager::GetInstance().AuthenticateURL(url2); if (result) { url->username = strdup(url2.GetUserName().c_str()); url->password = strdup(url2.GetPassWord().c_str()); } return result; }
bool CGUIDialogSimpleMenu::ShowPlaySelection(CFileItem& item) { /* if asked to resume somewhere, we should not show anything */ if (item.m_lStartOffset || (item.HasVideoInfoTag() && item.GetVideoInfoTag()->m_iBookmarkId > 0)) return true; if (CSettings::GetInstance().GetInt(CSettings::SETTING_DISC_PLAYBACK) != BD_PLAYBACK_SIMPLE_MENU) return true; std::string path; if (item.IsVideoDb()) path = item.GetVideoInfoTag()->m_strFileNameAndPath; else path = item.GetPath(); if (item.IsBDFile()) { std::string root = URIUtils::GetParentPath(path); URIUtils::RemoveSlashAtEnd(root); if (URIUtils::GetFileName(root) == "BDMV") { CURL url("bluray://"); url.SetHostName(URIUtils::GetParentPath(root)); url.SetFileName("root"); return ShowPlaySelection(item, url.Get()); } } if (item.IsDiscImage()) { CURL url2("udf://"); url2.SetHostName(item.GetPath()); url2.SetFileName("BDMV/index.bdmv"); if (XFILE::CFile::Exists(url2.Get())) { url2.SetFileName(""); CURL url("bluray://"); url.SetHostName(url2.Get()); url.SetFileName("root"); return ShowPlaySelection(item, url.Get()); } } return true; }
VMIME_TEST_LIST_END void testCreateFromURL() { vmime::shared_ptr <vmime::net::session> sess = vmime::net::session::create(); // POP3 vmime::utility::url url("pop3://pop3.vmime.org"); vmime::shared_ptr <vmime::net::store> store = sess->getStore(url); VASSERT_TRUE("pop3", typeid(*store) == typeid(vmime::net::pop3::POP3Store)); // POP3S vmime::utility::url url2("pop3s://pop3s.vmime.org"); vmime::shared_ptr <vmime::net::store> store2 = sess->getStore(url2); VASSERT_TRUE("pop3s", typeid(*store2) == typeid(vmime::net::pop3::POP3SStore)); }
Net::Request::Request(Session &session, const char *url, unsigned timeout_ms) { UTF8ToWideConverter url2(url); if (!url2.IsValid()) return; HINTERNET h = session.handle.OpenUrl(url2, NULL, 0, INTERNET_FLAG_NO_AUTH | INTERNET_FLAG_NO_AUTO_REDIRECT | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_NO_COOKIES | INTERNET_FLAG_NO_UI, (DWORD_PTR)this); if (h == NULL && GetLastError() == ERROR_IO_PENDING) // Wait until we get the Request handle opened_event.Wait(timeout_ms); }
bool CVFSEntry::ContainsFiles(const std::string& path, CFileItemList& items) { if (!Initialized()) return false; VFSDirEntry* entries; int num_entries; CURL url(path); CVFSURLWrapper url2(url); void* ctx = m_pStruct->ContainsFiles(&url2.url, &entries, &num_entries); if (!ctx) return false; VFSDirEntriesToCFileItemList(num_entries, entries, items); m_pStruct->FreeDirectory(ctx); return true; }
TEST(NetworkAccessManager, Get) { CustomNetworkAccessManagerFactory factory; QObjectPtr<QNetworkAccessManager> nam (factory.create(nullptr)); // Non-localhost:8080 Url QObjectPtr<QNetworkReply> reply1 (nam->get(QNetworkRequest(QUrl("http://www.google.com")))); while (!reply1->isFinished()) { QTest::qWait(100); } EXPECT_EQ(reply1->url(), QUrl()); EXPECT_NE(reply1->error(), QNetworkReply::NoError); // localhost:8080 Url QUrl url2 ("http://localhost:8080/ipfs/hash/test.png"); QObjectPtr<QNetworkReply> reply2 (nam->get(QNetworkRequest(url2))); EXPECT_EQ(reply2->url(), url2); QUrl url3 ("http://127.0.0.1:8080/ipfs/hash/test.png"); QObjectPtr<QNetworkReply> reply3 (nam->get(QNetworkRequest(url3))); EXPECT_EQ(reply3->url(), url3); }
bool CVFSEntry::ContainsFiles(const CURL& url, CFileItemList& items) { if (!m_struct.toAddon.contains_files || !m_struct.toAddon.free_directory) return false; VFSDirEntry* entries = nullptr; int num_entries = 0; CVFSURLWrapper url2(url); char rootpath[ADDON_STANDARD_STRING_LENGTH]; rootpath[0] = 0; bool ret = m_struct.toAddon.contains_files(&m_struct, &url2.url, &entries, &num_entries, rootpath); if (!ret) return false; VFSDirEntriesToCFileItemList(num_entries, entries, items); m_struct.toAddon.free_directory(&m_struct, entries, num_entries); if (strlen(rootpath)) items.SetPath(rootpath); return true; }
// public void addWebAction(QAction* action, QWebPage::WebAction webAction) void tst_TabWidget::addWebAction() { QFETCH(QWebPage::WebAction, webAction); SubTabWidget widget; QSignalSpy spy0(&widget, SIGNAL(linkHovered(const QString &))); QSignalSpy spy1(&widget, SIGNAL(loadPage(const QString &))); QSignalSpy spy2(&widget, SIGNAL(loadProgress(int))); QSignalSpy spy3(&widget, SIGNAL(setCurrentTitle(const QString &))); QSignalSpy spy4(&widget, SIGNAL(showStatusBarMessage(const QString &))); QSignalSpy spy5(&widget, SIGNAL(tabsChanged())); QSignalSpy spy6(&widget, SIGNAL(lastTabClosed())); QAction *action = new QAction(&widget); widget.addWebAction(action, webAction); widget.newTab(); QVERIFY(!action->isEnabled()); widget.loadUrl(QUrl("about:config")); QUrl url1(":/notfound.html"); //QUrl("http://www.google.com/")); QUrl url2(":/notfound2.html"); //QUrl("http://www.yahoo.com/")); widget.loadUrl(url1); widget.loadUrl(url2); QTRY_VERIFY(action->isEnabled()); widget.newTab(); QVERIFY(!action->isEnabled()); QCOMPARE(spy0.count(), 0); QCOMPARE(spy1.count(), 0); QVERIFY(spy2.count() > 0); QCOMPARE(spy3.count(), 8); QVERIFY(spy4.count() > 0); QCOMPARE(spy5.count(), 6); QCOMPARE(spy6.count(), 0); }
bool CVFSEntry::GetDirectory(const CURL& url, CFileItemList& items, void* ctx) { if (!m_struct.toAddon.get_directory || !m_struct.toAddon.free_directory) return false; VFSGetDirectoryCallbacks callbacks; callbacks.ctx = ctx; callbacks.get_keyboard_input = CVFSEntryIDirectoryWrapper::DoGetKeyboardInput; callbacks.set_error_dialog = CVFSEntryIDirectoryWrapper::DoSetErrorDialog; callbacks.require_authentication = CVFSEntryIDirectoryWrapper::DoRequireAuthentication; VFSDirEntry* entries = nullptr; int num_entries = 0; CVFSURLWrapper url2(url); bool ret = m_struct.toAddon.get_directory(&m_struct, &url2.url, &entries, &num_entries, &callbacks); if (ret) { VFSDirEntriesToCFileItemList(num_entries, entries, items); m_struct.toAddon.free_directory(&m_struct, entries, num_entries); } return ret; }