void HistoryManager::addHistoryEntry(const QString &url) { QUrl cleanUrl(url); cleanUrl.setPassword(QString()); cleanUrl.setHost(cleanUrl.host().toLower()); HistoryItem item(cleanUrl.toString(), QDateTime::currentDateTime()); addHistoryItem(item); }
void HistoryManager::addHistoryEntry(const QString &url) { QWebSettings *globalSettings = QWebSettings::globalSettings(); if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) return; QUrl cleanUrl(url); // don't store about: urls (home page related) if (cleanUrl.scheme() == QString("about")) return; cleanUrl.setPassword(QString()); cleanUrl.setHost(cleanUrl.host().toLower()); QString checkUrlString = cleanUrl.toString(); HistoryItem item; // NOTE // check if the url has just been visited. // if so, remove previous entry from history, update and prepend it if(historyContains(checkUrlString)) { int index = m_historyFilterModel->historyLocation(checkUrlString); item = m_history.at(index); m_history.removeOne(item); emit entryRemoved(item); item.dateTime = QDateTime::currentDateTime(); item.visitCount++; } else { item = HistoryItem(checkUrlString, QDateTime::currentDateTime()); } m_history.prepend(item); emit entryAdded(item); if (m_history.count() == 1) checkForExpired(); }
//String IOMLCode::encodeUrl(shared_ptr<OMLContext> context, shared_ptr<OMLItem> i, const String& href, OMLRenderUrlDestination& destination, bool onlyExternalWithoutConfirm) String IOMLCode::encodeUrl(shared_ptr<OMLContext> context, shared_ptr<OMLItem> i, const String& href, OMLRenderUrlDestination destination, bool onlyExternalWithoutConfirm) { if(context->getMode() == omlRenderModeSearch) // 0.15 return href; shared_ptr<const IPortalPage> portalPage = context->getPortalPage(); bool redirect = false; bool confirm = false; //String confirmMessage; String out = cleanUrl(context, href); OsirisLink osirisLink(out.to_ascii()); if(osirisLink.isValid()) { if(osirisLink.getType() == OsirisLink::linkPortal) { destination = omlRenderUrlDestinationSame; } else if(osirisLink.getType() == OsirisLink::linkIsis) { destination = omlRenderUrlDestinationSame; } else if(osirisLink.getType() == OsirisLink::linkUrl) { if(onlyExternalWithoutConfirm) return String::EMPTY; if(context->checkPortalPageAvailable(i) == false) return String::EMPTY; // Internal page url String urlPage = osirisLink.getParam("url"); if(urlPage.substr(0,1) != _S("/")) urlPage = _S("/") + urlPage; if( (urlPage.substr(0,9) == _S("/portals/")) ) { if(urlPage.find(_S("?")) == String::npos) urlPage += _S("?"); else urlPage += _S("&"); std::string pov; if(osirisLink.hasParam("portal")) pov = osirisLink.getPortal().getString(); else pov = portalPage->getPortal()->getPortalID().getString(); // Portal param maybe a Portal or a POV. if(pov.length() == 40) // If is a Portal, convert to POV. { PortalID portalID(pov); if(portalID == portalPage->getPortal()->getPortalID()) pov = Portal::generatePovID(portalID, portalPage->getPortal()->getPovID()); else { shared_ptr<Portal> externalPortal = PortalsSystem::instance()->getFirstPortal(portalID); if(externalPortal) pov = Portal::generatePovID(portalID, externalPortal->getPovID()); else { // We don't have the requested portal. return String::EMPTY; } } } else { shared_ptr<Portal> externalPortal = PortalsSystem::instance()->getPortalByFullPov(pov); if(externalPortal == nullptr) { // We don't have the requested portal. return String::EMPTY; } } urlPage += _S("portal=") + pov; /* // Normally the "portal" param is mandatory PortalID portalID = portalPage->getPortal()->getPortalID(); if(osirisLink.hasParam("portal")) portalID = osirisLink.getPortal(); // Normally the "user" param is absent. Because we want to avoid that changing POV will break urls. urlPage += _S("&user="******"user")) urlPage += osirisLink.getUser().getString(); else { // If the link is internal to the current portal, use the current user. if(portalID == portalPage->getPortal()->getPortalID()) urlPage += portalPage->getPortal()->getUserID().getString(); else { shared_ptr<Portal> externalPortal = PortalsSystem::instance()->getFirstPortal(portalID); if(externalPortal) urlPage += externalPortal->getUserID().getString(); else { // We don't have the requested portal. return String::EMPTY; } } } */ out = urlPage; //out = String::format(_S("%s").c_str(), url.toString()); } else { // Main url //out = String::format(_S("%S").c_str(), urlPage.c_str()); out = urlPage; } } else if(osirisLink.getType() == OsirisLink::linkFile) { if(onlyExternalWithoutConfirm) return String::EMPTY; if(context->checkPortalPageAvailable(i) == false) return String::EMPTY; // Internal file url out = portalPage->getPortal()->getFileLink(EntityID(String(osirisLink.getParam("id")).to_ascii())); } else context->addWarningInvalidUrl(i, out); if(context->getMode() == omlRenderModeExternal) out = IdeSystem::instance()->getLocalUrl(out); /* StringVector params; utils::split(out,_S("|"), params); if(params.size()<2) { context->addWarningInvalidUrl(i, out); return String::EMPTY; } if(params[1] == _S("portal")) { destination = omlRenderUrlDestinationSame; } else if(params[1] == _S("isis")) { destination = omlRenderUrlDestinationSame; } else if(params[1] == _S("url")) { if(onlyExternalWithoutConfirm) return String::EMPTY; if(params.size()<3) { context->addWarningInvalidUrl(i, out); return String::EMPTY; } // Internal page url String urlPage = params[2]; String urlParams = (params.size() == 3) ? String::EMPTY : params[3]; if(urlPage.substr(0,1) != _S("/")) urlPage = _S("/") + urlPage; if( (urlPage.substr(0,9) == _S("/portals/")) ) { // Portal url if(urlParams.find(OS_URL_PARAM_PORTAL + String(_S("="))) == String::npos) { if(context->checkPortalPageAvailable(i) == false) return String::EMPTY; if(!urlParams.empty()) urlParams += _S("&"); //urlParams += String::format(_S("%S=%S").c_str(), OS_URL_PARAM_PORTAL.c_str(),portalPage->getLoggedUser()->getPortal()->getID().toString().c_str()); urlParams.append(OS_URL_PARAM_PORTAL); urlParams.append("="); urlParams.append(portalPage->getLoggedUser()->getPortal()->getPortalID().getString()); urlParams.append("&"); urlParams.append(OS_URL_PARAM_USER); urlParams.append("="); urlParams.append(portalPage->getLoggedUser()->getPortal()->getUserID().getString()); } out = String::format(_S("%S?%S").c_str(), urlPage.c_str(),urlParams.c_str()); } else { // Main url out = String::format(_S("%S?%S").c_str(), urlPage.c_str(),urlParams.c_str()); } } else if(params[1] == _S("file")) { if(onlyExternalWithoutConfirm) return String::EMPTY; if(context->checkPortalPageAvailable(i) == false) return String::EMPTY; if(params.size()<3) { context->addWarningInvalidUrl(i, out); return String::EMPTY; } // Internal file url String oId = params[2]; out = portalPage->getLoggedUser()->getPortal()->getFileLink(ObjectID(oId.to_ascii())); } if(context->getMode() == omlRenderModeExternal) out = IdeSystem::instance()->getLocalUrl(out); */ } else { String protocol = extractProtocol(out); if(protocol == String::EMPTY) { // Osiris 0.13 // If protocol can't be determined, it's a relative url. Relative url are accepted. if(context->getMode() == omlRenderModeExternal) out = IdeSystem::instance()->getLocalUrl(out); } else { if(context->getMode() == omlRenderModeExternal) { redirect = false; confirm = false; } else { // Se non sono abilitati i link esterni if( (context->getSecure()) || (!bool(context->getPage()->getOption(Options::privacy_options::allow_external_urls))) ) { context->setSecureCheck(false); return String::EMPTY; } else { if(onlyExternalWithoutConfirm) { String protocolsCollectOption = context->getPage()->getOption(Options::url_options::protocols_collect); if(protocolsCollectOption.empty()) { return String::EMPTY; } else if(protocolsCollectOption == _S("*")) { redirect = false; confirm = false; } else if(regex_match(protocol, RegexManager::instance()->getRegex(_S("\\b(") + protocolsCollectOption + _S(")"), true))) { redirect = false; confirm = false; } else if(regex_match(out, RegexManager::instance()->getRegex(_S("\\b(") + protocolsCollectOption + _S(")\\b"), true))) { redirect = false; confirm = false; } else { return String::EMPTY; } } else { // Se il protocollo richiede una redirect // 0.12: Viene testato non solo il protocollo, ma anche l'url. Per ora, per supportare OffSystem. // Solo l'inizio dell'url, per evitare conflitti. String protocolsNoRedirectOption = context->getPage()->getOption(Options::url_options::protocols_no_redirect); if(protocolsNoRedirectOption.empty()) { redirect = true; } else if(protocolsNoRedirectOption == _S("*")) { redirect = false; destination = omlRenderUrlDestinationSame; } else if(regex_match(protocol, RegexManager::instance()->getRegex(_S("\\b(") + protocolsNoRedirectOption + _S(")\\b"), true))) { redirect = false; destination = omlRenderUrlDestinationSame; } else if(regex_match(out, RegexManager::instance()->getRegex(_S("\\b(") + protocolsNoRedirectOption + _S(")"), true))) { redirect = false; destination = omlRenderUrlDestinationSame; } else { redirect = true; } // Se il protocollo richiede una conferma // 0.12: Viene testato non solo il protocollo, ma anche l'url. Per ora, per supportare OffSystem. // Solo l'inizio dell'url, per evitare conflitti. String protocolsNoConfirmOption = context->getPage()->getOption(Options::url_options::protocols_no_confirm); if(protocolsNoConfirmOption.empty()) { confirm = true; } else if(protocolsNoConfirmOption == _S("*")) { confirm = false; } else if(regex_match(protocol, RegexManager::instance()->getRegex(_S("\\b(") + protocolsNoConfirmOption + _S(")"), true))) { confirm = false; } else if(regex_match(out, RegexManager::instance()->getRegex(_S("\\b(") + protocolsNoConfirmOption + _S(")\\b"), true))) { confirm = false; } else { confirm = true; } } } } } } // Encoding html //out = HttpParser::urlEncode(out); out = encode(context, out); // Basato su IPB 2.1, converto i '\' in '#092' // Questo perchè in un url se scrivo "\0040" viene interpretato quel carattere unicode. out.replace_all(_S("\\"), _S("#092")); if( (redirect) || (confirm) ) { // Added 0.12 out = String(context->getPage()->getOption(Options::web_options::redirect_url)).replace_all(_S("#url#"), out); out = PortalsSystem::instance()->getExternalLink(out.to_ascii(), confirm); } /* confirmMessage = encodeJavascriptString(confirmMessage); if((inNewWindow) || (!confirmMessage.empty())) out = String::format(_S("javascript:osRedirect('%S','%S',%d);").c_str(), out.c_str(),confirmMessage.c_str(),inNewWindow); */ return out; }
// Se è un url di un'immagine interna, valorizza in objectID l'oggetto a cui si riferisce. String IOMLCode::encodeResourceUrlEx(shared_ptr<OMLContext> context, shared_ptr<OMLItem> i, const String& href, String& entityID) { if(context->getMode() == omlRenderModeSearch) // 0.15 return href; String src = cleanUrl(context, href); OsirisLink osirisLink(src.to_ascii()); if(osirisLink.isValid()) { if(osirisLink.getType() == OsirisLink::linkResource) { src = context->getPage()->getSkin()->getResourceUrl(osirisLink.getParam("path")); if(src.empty()) { src = context->getPage()->getSkin()->getResourceUrl(_S("images/oml/img_missing.gif")); } if(context->getMode() == omlRenderModeExternal) src = IdeSystem::instance()->getLocalUrl(src); } else if(osirisLink.getType() == OsirisLink::linkFile) { shared_ptr<Portal> portal = nullptr; shared_ptr<const IPortalPage> page = context->getPortalPage(); if(osirisLink.hasParam("portal")) { PortalID portalID = osirisLink.getPortal(); if( (page != nullptr) && (portalID == page->getPortal()->getPortalID()) ) // Force the use of the current POV portal = page->getPortal(); else { portal = PortalsSystem::instance()->getFirstPortal(portalID); } } else { shared_ptr<const IPortalPage> page = context->getPortalPage(); if(page != nullptr) { portal = page->getPortal(); } } if(portal != nullptr) { String id = osirisLink.getParam("id"); shared_ptr<EntitiesEntity> entity = portal->getEntity(page->getDatabase(), EntityID(id.to_ascii())); shared_ptr<ObjectsIObject> current = entity ? entity->getCurrent() : nullptr; if( (current != nullptr) && (current->getObjectType() == portalObjectTypeFile) ) { src = portal->getFileLink(id.to_ascii()); entityID = id.to_ascii(); } else { src = context->getPage()->getSkin()->getResourceUrl(_S("images/oml/img_unknown.gif")); } if(context->getMode() == omlRenderModeExternal) src = IdeSystem::instance()->getLocalUrl(src); } } } else { String protocol = extractProtocol(src); if( (protocol == _S("http")) || (protocol == _S("https")) ) { if(context->getMode() == omlRenderModeExternal) { } else { // Check se sono abilitati i link esterni if((context->getSecure()) || (!bool(context->getPage()->getOption(Options::privacy_options::allow_external_images)))) { context->setSecureCheck(false); src = context->getPage()->getSkin()->getResourceUrl(_S("images/oml/img_notallowed.gif")); } } } else if(protocol == String::EMPTY) { // Osiris 0.13 // If protocol can't be determined, it's a relative url. Relative url are accepted. if(context->getMode() == omlRenderModeExternal) src = IdeSystem::instance()->getLocalUrl(src); return src; } else { context->addWarningInvalidUrl(i, src); src = String::EMPTY; } } return src; }