String CoaEncodedDiskMenuComponent::getFaction(TangibleObject* disk) { String name = disk->getObjectNameStringIdFile(); String faction; if (name.contains("imperial")) { faction = "imperial"; } else if (name.contains("rebel")) { faction = "rebel"; } return faction; }
// get hostname from string as url String String::getHostname() { String hostname; hostname = this->substr(0); if (hostname.contains("://")) hostname = hostname.after("://"); if (hostname.contains("/")) hostname = hostname.before("/"); if (hostname.contains("@")) // Contains a username:password combo hostname = hostname.after("@"); return hostname; }
// same for scan bypass void HTTPHeader::chopScanBypass(String url) { if (url.contains("GSBYPASS="******"?GSBYPASS="******"?GSBYPASS="******"?GSBYPASS="******"&GSBYPASS="******"&GSBYPASS="******""; }
void HTMLFormElement::parseEnctype(const String& type) { if(type.contains("multipart", false) || type.contains("form-data", false)) { m_enctype = "multipart/form-data"; m_multipart = true; } else if (type.contains("text", false) || type.contains("plain", false)) { m_enctype = "text/plain"; m_multipart = false; } else { m_enctype = "application/x-www-form-urlencoded"; m_multipart = false; } }
void FormSubmission::Attributes::parseEncodingType(const String& type) { if (type.contains("multipart", false) || type.contains("form-data", false)) { m_encodingType = "multipart/form-data"; m_isMultiPartForm = true; } else if (type.contains("text", false) || type.contains("plain", false)) { m_encodingType = "text/plain"; m_isMultiPartForm = false; } else { m_encodingType = "application/x-www-form-urlencoded"; m_isMultiPartForm = false; } }
//============================================================================== void CPUInformation::initialise() noexcept { const String flags (LinuxStatsHelpers::getCpuInfo ("flags")); hasMMX = flags.contains ("mmx"); hasSSE = flags.contains ("sse"); hasSSE2 = flags.contains ("sse2"); hasSSE3 = flags.contains ("sse3"); has3DNow = flags.contains ("3dnow"); hasSSSE3 = flags.contains ("ssse3"); hasAVX = flags.contains ("avx"); numCpus = LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1; }
// chop the GBYPASS or GIBYPASS variable out of a bypass URL // This function ASSUMES that you really know what you are doing // Do NOT run this function unless you know that the URL contains a valid bypass code // Ernest W Lessenger void HTTPHeader::chopBypass(String url, bool infectionbypass) { if (url.contains(infectionbypass ? "GIBYPASS="******"GBYPASS="******"?GIBYPASS="******"?GBYPASS="******"?GIBYPASS="******"?GBYPASS="******"?GIBYPASS="******"?GBYPASS="******"&GIBYPASS="******"&GBYPASS="******"&GIBYPASS="******"&GBYPASS="******""; }
bool HtmlScreen::project(Token *token, int i0, int i1) { String s = text_->copy(i0, i1); if (s->contains('<')) s = s->replace("<", "<"); if (s->contains('>')) s = s->replace(">", ">"); if (s->contains('\t')) s = s->replace("\t", " "); bool whitespace = s->countCharsIn(" \t\n\r") == s->count(); if (!whitespace) sink_ << "<span class=\"toki_" << hex(unsigned(token->scope())) << "_" << hex(token->rule()) << "\">"; sink_ << s; if (!whitespace) sink_ << "</span>"; return true; }
//============================================================================== void CPUInformation::initialise() noexcept { const String features (BSDStatsHelpers::getDmesgInfo (" Features=")); hasMMX = features.contains ("MMX"); hasSSE = features.contains ("SSE"); hasSSE2 = features.contains ("SSE2"); const String features2 (BSDStatsHelpers::getDmesgInfo (" Features2=")); hasSSE3 = features2.contains ("SSE3"); const String amdfeatures2 (BSDStatsHelpers::getDmesgInfo (" AMD Features2=")); has3DNow = amdfeatures2.contains ("3DNow!"); GETSYSCTL("hw.ncpu", numCpus); if (numCpus == -1) numCpus = 1; }
///----------------------------------------------------------------------------- void TwindyApp::initialise(const String& commandLine) { Rectangle recadendrum = Desktop::getInstance().getMainMonitorArea(); if (commandLine.contains(T("--help"))) { cout << "Twindy Window Manager" << endl; cout << "Version: " << ProjectInfo::versionString << endl; cout << endl; cout << "Usage:" << endl; cout << "twindy --version --help" << endl; cout << endl; quit(); } else if(commandLine.contains(T("--version"))) { cout << "Twindy Window Manager" << endl; cout << "Version: " << ProjectInfo::versionString << endl; cout << endl; quit(); } TWINDY_DBG_MESSAGE("Creating TwindyRootWindow."); win = new TwindyRootWindow(); TWINDY_DBG_MESSAGE("TwindyRootWindow created."); win->centreWithSize(recadendrum.getWidth(), recadendrum.getHeight()); TWINDY_DBG_MESSAGE("TwindyRootWindow centred and sized."); win->toFront(true); TWINDY_DBG_MESSAGE("TwindyRootWindow brought to front."); if (std::getenv("TWINDY_SKIP_JACKD_START") != nullptr) return restartMODApp(1); TwindyPreferences* const prefs(win->getPreferencesPanel()); AlertWindow w(T("Live-MOD"), T("Welcome to Live-MOD!"), AlertWindow::NoIcon); w.addTextBlock(T("Before we begin please select which soundcard you plan to use.")); w.addTextBlock(T("If you're not sure which to use, select the first one.")); w.addComboBox(T("audioDeviceList"), prefs->getAudioDevices(), T("Soundcard:")); w.addButton(T("Ok"), 5, '\n'); if (w.runModalLoop() == 5) { if (ComboBox* const box = w.getComboBoxComponent(T("audioDeviceList"))) prefs->selectAudioDevice(box->getText()); } }
int CoaMessageFragmentMenuComponent::handleObjectMenuSelect(SceneObject* sceneObject, CreatureObject* player, byte selectedID) { if (!player->isPlayerCreature()) { return 0; } if (!sceneObject->isASubChildOf(player)) { player->sendSystemMessage("@encoded_disk/message_fragment:sys_not_in_inv"); // The disk can't be used unless it is in your inventory! return 0; } TangibleObject* fragment = cast<TangibleObject*>(sceneObject); if (fragment == NULL) { return 0; } PlayerObject* ghost = player->getPlayerObject(); if (ghost == NULL) { return 0; } if (selectedID == 20) { String title = fragment->getCustomObjectName().toString(); StringBuffer body; body << "@encoded_disk/message_fragment:text_event"; if (title.contains("Imperial")) { body << "imp1"; } else if (title.contains("Rebel")) { body << "reb1"; } else { return 0; } ManagedReference<SuiMessageBox*> box = new SuiMessageBox(player, SuiWindowType::COA_MESSAGE_FRAGMENT); box->setCallback(new CoaMessageFragmentSuiCallback(player->getZoneServer())); box->setPromptTitle(title); box->setPromptText(body.toString()); box->setUsingObject(fragment); box->setCancelButton(true, "@close"); box->setOkButton(true, "@encoded_disk/message_fragment:combine"); ghost->addSuiBox(box); player->sendMessage(box->generateMessage()); return 0; } return TangibleObjectMenuComponent::handleObjectMenuSelect(sceneObject, player, selectedID); }
WebVTTParser::ParseState WebVTTParser::collectCueId(const String& line) { if (line.contains("-->")) return collectTimingsAndSettings(line); m_currentId = line; return TimingsAndSettings; }
void setCookies(const KURL& url, const KURL& policyURL, const String& value) { #if USE(CFNETWORK) CFHTTPCookieStorageRef defaultCookieStorage = wkGetDefaultHTTPCookieStorage(); if (!defaultCookieStorage) return; RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL()); RetainPtr<CFURLRef> policyURLCF(AdoptCF, policyURL.createCFURL()); // <http://bugzilla.opendarwin.org/show_bug.cgi?id=6531>, <rdar://4409034> // cookiesWithResponseHeaderFields doesn't parse cookies without a value String cookieString = value.contains('=') ? value : value + "="; RetainPtr<CFStringRef> cookieStringCF(AdoptCF, cookieString.createCFString()); RetainPtr<CFDictionaryRef> headerFieldsCF(AdoptCF, CFDictionaryCreate(kCFAllocatorDefault, (const void**)&s_setCookieKeyCF, (const void**)&cookieStringCF, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieCreateWithResponseHeaderFields(kCFAllocatorDefault, headerFieldsCF.get(), urlCF.get())); CFHTTPCookieStorageSetCookies(defaultCookieStorage, cookiesCF.get(), urlCF.get(), policyURLCF.get()); #else // FIXME: Deal with the policy URL. DeprecatedString str = url.url(); str.append((UChar)'\0'); DeprecatedString val = value.deprecatedString(); val.append((UChar)'\0'); InternetSetCookie((UChar*)str.unicode(), 0, (UChar*)val.unicode()); #endif }
bool SubframeLoader::shouldUsePlugin(const URL& url, const String& mimeType, bool shouldPreferPlugInsForImages, bool hasFallback, bool& useFallback) { #if PLATFORM(JS) return false; #else if (m_frame.loader().client().shouldAlwaysUsePluginDocument(mimeType)) { useFallback = false; return true; } // Allow other plug-ins to win over QuickTime because if the user has installed a plug-in that // can handle TIFF (which QuickTime can also handle) they probably intended to override QT. if (m_frame.page() && (mimeType == "image/tiff" || mimeType == "image/tif" || mimeType == "image/x-tiff")) { String pluginName = m_frame.page()->pluginData().pluginNameForMimeType(mimeType); if (!pluginName.isEmpty() && !pluginName.contains("QuickTime", false)) return true; } ObjectContentType objectType = m_frame.loader().client().objectContentType(url, mimeType, shouldPreferPlugInsForImages); // If an object's content can't be handled and it has no fallback, let // it be handled as a plugin to show the broken plugin icon. useFallback = objectType == ObjectContentNone && hasFallback; return objectType == ObjectContentNone || objectType == ObjectContentNetscapePlugin || objectType == ObjectContentOtherPlugin; #endif }
Value::Text DictionaryValue::asText() const { Text result; QTextStream s(&result); s << "{"; bool isFirst = true; bool hadNewline = false; // Compose a textual representation of the array elements. for (Elements::const_iterator i = _elements.begin(); i != _elements.end(); ++i) { String const label = i->first.value->asText() + ": "; String content = i->second->asText(); bool const multiline = content.contains('\n'); if (!isFirst) { if (hadNewline || multiline) s << "\n"; s << ","; } hadNewline = multiline; s << " " << label << content.replace("\n", "\n" + String(label.size() + 2, ' ')); isFirst = false; } s << " }"; return result; }
/** this will validate pause message @param[in] message message string @return bool true if client is puase */ bool isPauseMessage(const String & message) { if(message.contains(pauseMessageID)) return true; else return false; }
/** this will validate stop message @param[in] message message string @return bool true if client is stop */ bool isStopMessage(const String & message) { if(message.contains(stopMessageID)) return true; else return false; }
static bool isEndOfCommentBlock (const String& line) { if (line.contains ("*/")) return true; return false; }
void setCookies(Document* document, const KURL& url, const String& value) { // <rdar://problem/5632883> CFHTTPCookieStorage stores an empty cookie, which would be sent as "Cookie: =". if (value.isEmpty()) return; CFHTTPCookieStorageRef cookieStorage = currentCookieStorage(); if (!cookieStorage) return; RetainPtr<CFURLRef> urlCF(AdoptCF, url.createCFURL()); RetainPtr<CFURLRef> firstPartyForCookiesCF(AdoptCF, document->firstPartyForCookies().createCFURL()); // <http://bugs.webkit.org/show_bug.cgi?id=6531>, <rdar://4409034> // cookiesWithResponseHeaderFields doesn't parse cookies without a value String cookieString = value.contains('=') ? value : value + "="; RetainPtr<CFStringRef> cookieStringCF(AdoptCF, cookieString.createCFString()); RetainPtr<CFDictionaryRef> headerFieldsCF(AdoptCF, CFDictionaryCreate(kCFAllocatorDefault, (const void**)&s_setCookieKeyCF, (const void**)&cookieStringCF, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); RetainPtr<CFArrayRef> cookiesCF(AdoptCF, CFHTTPCookieCreateWithResponseHeaderFields(kCFAllocatorDefault, headerFieldsCF.get(), urlCF.get())); CFHTTPCookieStorageSetCookies(cookieStorage, filterCookies(cookiesCF.get()).get(), urlCF.get(), firstPartyForCookiesCF.get()); }
/** this will validate next message @param[in] message message string @return bool true if next message */ bool isNextMessage(const String & message) { if(message.contains(nextMessageID)) return true; else return false; }
/** this will validate back message @param[in] message message string @return bool true if back message */ bool isBackMessage(const String & message) { if(message.contains(backMessageID)) return true; else return false; }
bool WMLPageState::pathIsAllowedToAccess(const String& path) const { // Spec: The access path is prefix matched against the path portion of the referring URI Vector<String> subpathsAllowed; if (m_accessPath.contains('/')) m_accessPath.split('/', subpathsAllowed); else subpathsAllowed.append(m_accessPath); Vector<String> subpathsCheck; if (path.contains('/')) path.split('/', subpathsCheck); else subpathsCheck.append(path); Vector<String>::iterator itAllowed = subpathsAllowed.begin(); Vector<String>::iterator endAllowed = subpathsAllowed.end(); Vector<String>::iterator itCheck = subpathsCheck.begin(); Vector<String>::iterator endCheck = subpathsCheck.end(); bool pathOk = true; for (; itAllowed != endAllowed && itCheck != endCheck; ) { if (*itAllowed != *itCheck) { pathOk = false; break; } ++itAllowed; ++itCheck; } return pathOk; }
/** this will validate acquireLock message for server @param[in] message message string @return bool true if allowLock message */ bool isAllowLockMessage(const String & message) { if(message.contains(allowLockID)) return true; else return false; }
/** this will validate denyLock message for server @param[in] message message string @return bool true if denyLock message */ bool isServerIsUnLockedMessage(const String & message) { if(message.contains(serverIsUnLockedID)) return true; else return false; }
/** this will validate denyLock message for server @param[in] message message string @return bool true if denyLock message */ bool isDenyLockMessage(const String & message) { if(message.contains(denyLockID)) return true; else return false; }
/** this will validate releaseLock message for server @param[in] message message string @return bool true if releaseLock message */ bool isReleaseLockMessage(const String & message) { if(message.contains(releaseLockID)) return true; else return false; }
bool WMLPageState::hostIsAllowedToAccess(const String& host) const { // Spec: The access domain is suffix-matched against the domain name portion of the referring URI Vector<String> subdomainsAllowed; if (m_accessDomain.contains('.')) m_accessDomain.split('.', subdomainsAllowed); else subdomainsAllowed.append(m_accessDomain); Vector<String> subdomainsCheck; if (host.contains('.')) host.split('.', subdomainsCheck); else subdomainsCheck.append(host); Vector<String>::iterator itAllowed = subdomainsAllowed.end() - 1; Vector<String>::iterator beginAllowed = subdomainsAllowed.begin(); Vector<String>::iterator itCheck = subdomainsCheck.end() - 1; Vector<String>::iterator beginCheck = subdomainsCheck.begin(); bool hostOk = true; for (; itAllowed >= beginAllowed && itCheck >= beginCheck; ) { if (*itAllowed != *itCheck) { hostOk = false; break; } --itAllowed; --itCheck; } return hostOk; }
void Halley::INIFile::parse(String data) { //std::cout << "Parsing ini data: [[\n" << data << "]]\n"; entries.clear(); if (data != "") { char* str = &data[0]; char* cur = strtok(str, "\n"); String group = ""; while (cur != nullptr) { String line = cur; line.trimBoth(); if (line != "") { if (line.startsWith("[") && line.endsWith("]")) { group = line.mid(1, line.length()-2); } else if (!line.startsWith("#") && line.contains("=")) { size_t pos = line.find('='); String key = line.left(pos).asciiLower(); String value = line.mid(pos+1); key.trimBoth(); value.trimBoth(); entries[group+"."+key] = value; } } cur = strtok(nullptr, "\n"); } } }
void ObjController::removeAudioConnection(AudioOutConnector* aocComp, bool undoable, ObjectsHolder* holder) { if(undoable) { owner.getUndoManager().perform(new RemoveAudioConnectionAction(holder, aocComp, this)); } else { sObjects.deselect(aocComp); sObjects.changed(true); ValueTree sources = aocComp->getAudioObject()->getData().getChildWithName(Ids::sources); ValueTree source; for (int i = 0; i < sources.getNumChildren(); ++i) { String val = sources.getChild(i)[Ids::value]; // DBG(aocComp->getSourceObject()->getData()[Ids::identifier].toString()); if(val.contains(aocComp->getSourceObject()->getData()[Ids::identifier].toString())) { source = sources.getChild(i); break; } } sources.removeChild(source, nullptr); audioConnections.removeObject(aocComp); } }
void HTMLElement::setInnerText(const String& text, ExceptionCode& ec) { if (ieForbidsInsertHTML()) { ec = NO_MODIFICATION_ALLOWED_ERR; return; } if (hasLocalName(colTag) || hasLocalName(colgroupTag) || hasLocalName(framesetTag) || hasLocalName(headTag) || hasLocalName(htmlTag) || hasLocalName(tableTag) || hasLocalName(tbodyTag) || hasLocalName(tfootTag) || hasLocalName(theadTag) || hasLocalName(trTag)) { ec = NO_MODIFICATION_ALLOWED_ERR; return; } // FIXME: This doesn't take whitespace collapsing into account at all. if (!text.contains('\n') && !text.contains('\r')) { if (text.isEmpty()) { removeChildren(); return; } replaceChildrenWithText(this, text, ec); return; } // FIXME: Do we need to be able to detect preserveNewline style even when there's no renderer? // FIXME: Can the renderer be out of date here? Do we need to call updateStyleIfNeeded? // For example, for the contents of textarea elements that are display:none? RenderObject* r = renderer(); if (r && r->style()->preserveNewline()) { if (!text.contains('\r')) { replaceChildrenWithText(this, text, ec); return; } String textWithConsistentLineBreaks = text; textWithConsistentLineBreaks.replace("\r\n", "\n"); textWithConsistentLineBreaks.replace('\r', '\n'); replaceChildrenWithText(this, textWithConsistentLineBreaks, ec); return; } // Add text nodes and <br> elements. ec = 0; RefPtr<DocumentFragment> fragment = textToFragment(text, ec); if (!ec) replaceChildrenWithFragment(this, fragment.release(), ec); }