Example #1
0
bool isValidHTTPHeaderValue(const String& name)
{
    // FIXME: This should really match name against
    // field-value in section 4.2 of RFC 2616.

    return !name.contains('\r') && !name.contains('\n');
}
Example #2
0
void NoteMapHandler::paintListBoxItem (int row, Graphics& g, int w, int h, bool selected)
{
    if (map)
    {
        g.setFont (Font(11.0f));
        String inName = MidiMessage::getMidiNoteName (row, true,true,octaveMiddleC);
        String inCh = String(inputChannel->getSelectedChannel ());
        String outName = MidiMessage::getMidiNoteName (map->getOutputNoteFor (row), true,true,octaveMiddleC);
        String outCh = String(map->getOutputChannelFor (row));
        if (inName.contains (T("#")))
        {
            g.setColour (Colours::darkgrey);
            g.fillRect  (0,0,w/2,h);
            g.setColour (Colours::white);
        }
        else g.setColour (Colours::black);
        g.drawFittedText (inName,20,0,w/2-20,h,Justification::centred,1);
        g.drawFittedText (inCh,0,0,20,h,Justification::centred,1);

        if (outName.contains (T("#")))
        {
            g.setColour (Colours::darkgrey);
            g.fillRect  (w/2,0,w/2,h);
            g.setColour (Colours::white);
        }
        else g.setColour (Colours::black);
        g.drawFittedText (outName,w/2,0,w/2-20,h,Justification::centred,1);
        g.drawFittedText (outCh,w-20,0,20,h,Justification::centred,1);

        if (selected) g.fillAll (Colours::orange.withAlpha (0.3f));
    }
}
Example #3
0
int Request::timeParamToSeconds(String param)
{
	try {
		int s = 0;

		if(param.contains("h"))
		{
			String hours = param;
			param = hours.cut('h');
			s+= hours.toInt()*3600;

			if(!param.contains("m") && !param.contains("s"))
				param+= 'm';
		}

		if(param.contains("m"))
		{
			String minutes = param;
			param = minutes.cut('m');
			s+= minutes.toInt()*60;
		}

		param.cut('s');
		s+= param.toInt();
		return s;
	}
	catch(const std::exception &e)
	{
		return -1;
	}
}
bool isValidHTTPHeaderValue(const String& name)
{
    // FIXME: This should really match name against
    // field-value in section 4.2 of RFC 2616.

    return name.containsOnlyLatin1() && !name.contains('\r') && !name.contains('\n') && !name.contains(static_cast<UChar>('\0'));
}
Example #5
0
void MarkupAccumulator::appendQuotedURLAttributeValue(StringBuilder& result, const Element& element, const Attribute& attribute)
{
    ASSERT(element.isURLAttribute(attribute));
    const String resolvedURLString = resolveURLIfNeeded(element, attribute.value());
    UChar quoteChar = '"';
    String strippedURLString = resolvedURLString.stripWhiteSpace();
    if (protocolIsJavaScript(strippedURLString)) {
        // minimal escaping for javascript urls
        if (strippedURLString.contains('"')) {
            if (strippedURLString.contains('\''))
                strippedURLString.replaceWithLiteral('"', "&quot;");
            else
                quoteChar = '\'';
        }
        result.append(quoteChar);
        result.append(strippedURLString);
        result.append(quoteChar);
        return;
    }

    // FIXME: This does not fully match other browsers. Firefox percent-escapes non-ASCII characters for innerHTML.
    result.append(quoteChar);
    appendAttributeValue(result, resolvedURLString, false);
    result.append(quoteChar);
}
Example #6
0
//==============================================================================
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");
}
Example #7
0
bool checkGameGUIOption(const String &option, const String &str) {
	for (int i = 0; g_gameOptions[i].desc; i++) {
		if (option.contains(g_gameOptions[i].option)) {
			if (str.contains(g_gameOptions[i].desc))
				return true;
			else
				return false;
		}
	}
	return false;
}
Example #8
0
    String simplifyPath (const String& path)
    {
       #if JUCE_WINDOWS
        if (path.contains ("\\..\\") || path.contains ("/../"))
       #else
        if (path.contains ("/../"))
       #endif
            return simplifyPath (path.getCharPointer());

        return path;
    }
Example #9
0
///-----------------------------------------------------------------------------
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());
    }
}
Example #10
0
 /** 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;
 }
Example #11
0
 /** 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;
 }
Example #12
0
 /** 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;
 }
Example #13
0
 /** 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;
 }
Example #14
0
 /** 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;
 }
Example #15
0
 /** 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;
 }
Example #16
0
 /** 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;
 }
Example #17
0
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;
}
Example #18
0
 /** 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;
 }
Example #19
0
WebVTTParser::ParseState WebVTTParser::collectCueId(const String& line)
{
    if (line.contains("-->"))
        return collectTimingsAndSettings(line);
    m_currentId = line;
    return TimingsAndSettings;
}
Example #20
0
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());
}
Example #21
0
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);
}
Example #22
0
VTTParser::ParseState VTTParser::ignoreBadCue(const String& line)
{
    if (line.isEmpty())
        return Id;
    if (line.contains("-->"))
        return recoverCue(line);
    return BadCue;
}
int HTTPHandler::sendGetRequest(String url)
{
    std::string ip;
    String request;
    String host;

#if 0
    /* get the host and url */
    if(url.contains("/"))
    {
        host = url.before("/");
        url = url.after("/");
    }
    else
    {
        host = url;
        url = "";
    }

    if(!url.empty())
    {
    request = "GET " + url + " HTTP 1.0\r\n";
    request += "Host: " + host + "\r\n\r\n";
    }
    else
    {
    }
#else
    if(url.contains("/"))
    {
        host = url.before("/");
    }
    else
    {
        host = url;
    }
    request = "GET http://" + url + " HTTP/1.0\r\n\r\n";
#endif

    /* get the ip addr */
    hostname_to_ip(host,ip);

    mpSocket = new Socket(ip,80);
    return mpSocket->write(request);
}
Example #24
0
String parseGameGUIOptions(const String &str) {
	String res;

	for (int i = 0; g_gameOptions[i].desc; i++)
		if (str.contains(g_gameOptions[i].desc))
			res += g_gameOptions[i].option;

	return res;
}
Example #25
0
static void testNumberIsReversible(LCID lcid, const char* original, const char* shouldHave = 0)
{
    OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
    String localized = locale->convertToLocalizedNumber(original);
    if (shouldHave)
        EXPECT_TRUE(localized.contains(shouldHave));
    String converted = locale->convertFromLocalizedNumber(localized);
    EXPECT_STREQ(original, converted.utf8().data());
}
Example #26
0
String findMarkedSegment(String segmented, const String& marker)
{
    if(!segmented.contains(marker)) return ""; // Not present.

    int pos = segmented.indexOf(marker);
    int end = findAnyMarker(segmented, pos + marker.size());
    if(end < 0) end = segmented.size();
    return segmented.mid(pos + marker.size(), end - pos - marker.size());
}
Example #27
0
void testNumberIsReversible(const AtomicString& localeIdentifier, const char* original, const char* shouldHave = 0)
{
    OwnPtr<Locale> locale = Locale::create(localeIdentifier);
    String localized = locale->convertToLocalizedNumber(original);
    if (shouldHave)
        EXPECT_TRUE(localized.contains(shouldHave));
    String converted = locale->convertFromLocalizedNumber(localized);
    EXPECT_EQ(original, converted);
}
Example #28
0
void HTMLElement::setOuterText(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;
    }

    ContainerNode* parent = parentNode();
    if (!parent) {
        ec = NO_MODIFICATION_ALLOWED_ERR;
        return;
    }

    RefPtr<Node> prev = previousSibling();
    RefPtr<Node> next = nextSibling();
    RefPtr<Node> newChild;
    ec = 0;

    // Convert text to fragment with <br> tags instead of linebreaks if needed.
    if (text.contains('\r') || text.contains('\n'))
        newChild = textToFragment(text, ec);
    else
        newChild = Text::create(document(), text);

    if (!this || !parentNode())
        ec = HIERARCHY_REQUEST_ERR;
    if (ec)
        return;
    parent->replaceChild(newChild.release(), this, ec);

    RefPtr<Node> node = next ? next->previousSibling() : 0;
    if (!ec && node && node->isTextNode())
        mergeWithNextTextNode(node.release(), ec);

    if (!ec && prev && prev->isTextNode())
        mergeWithNextTextNode(prev.release(), ec);
}
Example #29
0
void HTMLElement::setOuterText(const String& text, ExceptionState& exceptionState)
{
    if (ieForbidsInsertHTML()) {
        exceptionState.throwDOMException(NoModificationAllowedError, "The '" + localName() + "' element does not support text insertion.");
        return;
    }
    if (shouldProhibitSetInnerOuterText(*this)) {
        exceptionState.throwDOMException(NoModificationAllowedError, "The '" + localName() + "' element does not support text insertion.");
        return;
    }

    ContainerNode* parent = parentNode();
    if (!parent) {
        exceptionState.throwDOMException(NoModificationAllowedError, "The element has no parent.");
        return;
    }

    RefPtrWillBeRawPtr<Node> prev = previousSibling();
    RefPtrWillBeRawPtr<Node> next = nextSibling();
    RefPtrWillBeRawPtr<Node> newChild = nullptr;

    // Convert text to fragment with <br> tags instead of linebreaks if needed.
    if (text.contains('\r') || text.contains('\n'))
        newChild = textToFragment(text, exceptionState);
    else
        newChild = Text::create(document(), text);

    // textToFragment might cause mutation events.
    if (!parentNode())
        exceptionState.throwDOMException(HierarchyRequestError, "The element has no parent.");

    if (exceptionState.hadException())
        return;

    parent->replaceChild(newChild.release(), this, exceptionState);

    RefPtrWillBeRawPtr<Node> node = next ? next->previousSibling() : nullptr;
    if (!exceptionState.hadException() && node && node->isTextNode())
        mergeWithNextTextNode(toText(node.get()), exceptionState);

    if (!exceptionState.hadException() && prev && prev->isTextNode())
        mergeWithNextTextNode(toText(prev.get()), exceptionState);
}
Example #30
0
void HTMLElement::setInnerText(const String& text, ExceptionState& exceptionState)
{
    if (ieForbidsInsertHTML()) {
        exceptionState.throwDOMException(NoModificationAllowedError, "The '" + localName() + "' element does not support text insertion.");
        return;
    }
    if (shouldProhibitSetInnerOuterText(*this)) {
        exceptionState.throwDOMException(NoModificationAllowedError, "The '" + localName() + "' element does not support text insertion.");
        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, exceptionState);
        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?
    LayoutObject* r = layoutObject();
    if (r && r->style()->preserveNewline()) {
        if (!text.contains('\r')) {
            replaceChildrenWithText(this, text, exceptionState);
            return;
        }
        String textWithConsistentLineBreaks = text;
        textWithConsistentLineBreaks.replace("\r\n", "\n");
        textWithConsistentLineBreaks.replace('\r', '\n');
        replaceChildrenWithText(this, textWithConsistentLineBreaks, exceptionState);
        return;
    }

    // Add text nodes and <br> elements.
    RefPtrWillBeRawPtr<DocumentFragment> fragment = textToFragment(text, exceptionState);
    if (!exceptionState.hadException())
        replaceChildrenWithFragment(this, fragment.release(), exceptionState);
}