DeprecatedString String::deprecatedString() const { if (!m_impl) return DeprecatedString::null; if (!m_impl->characters()) return DeprecatedString("", 0); return DeprecatedString(reinterpret_cast<const DeprecatedChar*>(m_impl->characters()), m_impl->length()); }
int RegularExpression::match(const DeprecatedString &str, int startFrom, int *matchLength) const { #ifdef __OWB_JS__ d->lastMatchString = str; // First 2 offsets are start and end offsets; 3rd entry is used internally by pcre d->lastMatchCount = pcre_exec(d->regex, NULL, reinterpret_cast<const uint16_t *>(d->lastMatchString.unicode()), d->lastMatchString.length(), startFrom, startFrom == 0 ? 0 : PCRE_NOTBOL, d->lastMatchOffsets, maxOffsets); if (d->lastMatchCount < 0) { if (d->lastMatchCount != PCRE_ERROR_NOMATCH) LOG_ERROR("RegularExpression: pcre_exec() failed with result %d", d->lastMatchCount); d->lastMatchPos = -1; d->lastMatchLength = -1; d->lastMatchString = DeprecatedString(); return -1; } // 1 means 1 match; 0 means more than one match. First match is recorded in offsets. //ASSERT(d->lastMatchCount < 2); d->lastMatchPos = d->lastMatchOffsets[0]; d->lastMatchLength = d->lastMatchOffsets[1] - d->lastMatchOffsets[0]; if (matchLength != NULL) { *matchLength = d->lastMatchLength; } return d->lastMatchPos; #else return -1; #endif }
static DeprecatedString getTagName(void *node) { SVGStyledElement *elem = static_cast<SVGStyledElement *>(node); if (elem) return String(elem->nodeName()).deprecatedString(); return DeprecatedString(); }
void XMLHttpRequest::open(const String& method, const KURL& url, bool async, const String& user, const String& password, ExceptionCode& ec) { abort(); m_aborted = false; // clear stuff from possible previous load m_requestHeaders = DeprecatedString(); m_responseHeaders = String(); m_response = DeprecatedString(); m_createdDocument = false; m_responseXML = 0; changeState(Uninitialized); if (m_aborted) return; if (!urlMatchesDocumentDomain(url)) return; if (!isValidToken(method)) { ec = SYNTAX_ERR; return; } m_url = url; if (!user.isNull()) m_url.setUser(user.deprecatedString()); if (!password.isNull()) m_url.setPass(password.deprecatedString()); // Method names are case sensitive. But since Firefox uppercases method names it knows, we'll do the same. String methodUpper(method.upper()); if (methodUpper == "CONNECT" || methodUpper == "COPY" || methodUpper == "DELETE" || methodUpper == "GET" || methodUpper == "HEAD" || methodUpper == "INDEX" || methodUpper == "LOCK" || methodUpper == "M-POST" || methodUpper == "MKCOL" || methodUpper == "MOVE" || methodUpper == "OPTIONS" || methodUpper == "POST" || methodUpper == "PROPFIND" || methodUpper == "PROPPATCH" || methodUpper == "PUT" || methodUpper == "TRACE" || methodUpper == "UNLOCK") m_method = methodUpper.deprecatedString(); else m_method = method.deprecatedString(); m_async = async; changeState(Loading); }
bool DOMImplementation::isXMLMIMEType(const String& mimeType) { if (mimeType == "text/xml" || mimeType == "application/xml" || mimeType == "text/xsl") return true; static const char* validChars = "[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]"; // per RFCs: 3023, 2045 static RegularExpression xmlTypeRegExp(DeprecatedString("^") + validChars + "+/" + validChars + "+\\+xml$"); if (xmlTypeRegExp.match(mimeType.deprecatedString()) > -1) return true; return false; }
DeprecatedString RegularExpression::cap(int n) const { const pcre_char *substring = NULL; int substringLength = pcre_get_substring(reinterpret_cast<const uint16_t *>(d->lastMatchString.unicode()), d->lastMatchOffsets, d->lastMatchCount, n, &substring); if (substringLength > 0) { DeprecatedString capture(reinterpret_cast<const DeprecatedChar *>(substring), substringLength); pcre_free_substring(substring); return capture; } return DeprecatedString(); }
DeprecatedString StreamingTextDecoderICU::convertUsingICU(const unsigned char* chs, int len, bool flush) { // Get a converter for the passed-in encoding. if (!m_converterICU) { createICUConverter(); if (!m_converterICU) return DeprecatedString(); } DeprecatedString result(""); result.reserve(len); UChar buffer[ConversionBufferSize]; const char* source = reinterpret_cast<const char*>(chs); const char* sourceLimit = source + len; int32_t* offsets = NULL; UErrorCode err; do { UChar* target = buffer; const UChar* targetLimit = target + ConversionBufferSize; err = U_ZERO_ERROR; ucnv_toUnicode(m_converterICU, &target, targetLimit, &source, sourceLimit, offsets, flush, &err); int count = target - buffer; appendOmittingBOM(result, reinterpret_cast<const UChar*>(buffer), count * sizeof(UChar)); } while (err == U_BUFFER_OVERFLOW_ERROR); if (U_FAILURE(err)) { // flush the converter so it can be reused, and not be bothered by this error. do { UChar *target = buffer; const UChar *targetLimit = target + ConversionBufferSize; err = U_ZERO_ERROR; ucnv_toUnicode(m_converterICU, &target, targetLimit, &source, sourceLimit, offsets, true, &err); } while (source < sourceLimit); LOG_ERROR("ICU conversion error"); return DeprecatedString(); } return result; }
void setCookies(const KURL& url, const KURL& policyURL, const String& value) { DeprecatedString str = url.url(); DeprecatedString result("Set-Cookie:"); DeprecatedString val = value.deprecatedString(); //add everything in the cookie result.append(val); //Check if it had appended domain, path bool noDomainSet = !val.contains(DeprecatedString("domain=")); bool noPathSet = !val.contains(DeprecatedString("path=")); if(noDomainSet || noPathSet) { char pathBuffer[SIZE_OF_LATIN1_BUFFERS]; char domainBuffer[SIZE_OF_LATIN1_BUFFERS]; int tl_domainLocationInUrlBegins = str.find("://") + SIZE_OF_COLONSLASHSLASH; int tl_domainLocationInUrlEnds = str.find("/",tl_domainLocationInUrlBegins) - 1; result.append(';'); if(noDomainSet) { str.copyLatin1(domainBuffer, tl_domainLocationInUrlBegins, tl_domainLocationInUrlEnds - tl_domainLocationInUrlBegins + 1); domainBuffer[tl_domainLocationInUrlEnds - tl_domainLocationInUrlBegins + 1] = '\0'; result.append(DeprecatedString(" domain=")); result.append(DeprecatedString::fromLatin1(domainBuffer)); result.append(';'); } if(noPathSet) { int tl_pathLocationInUrlEnds = str.findRev("/"); str.copyLatin1(pathBuffer, tl_domainLocationInUrlEnds + 1, // 1 because it'll include '/' tl_pathLocationInUrlEnds - tl_domainLocationInUrlEnds ); pathBuffer[tl_pathLocationInUrlEnds = tl_domainLocationInUrlEnds] = '\0'; result.append(DeprecatedString(" path=")); result.append(DeprecatedString::fromLatin1(pathBuffer)); result.append(';'); } } if(val.startsWith(DeprecatedString("https://"))) { result.append(DeprecatedString(" secure")); } //Connect with Runtime. // WebKitApollo::g_HostFunctions->setJavaScriptCookie(result.latin1()); }
DeprecatedStringList DeprecatedStringList::split(const DeprecatedChar &separator, const DeprecatedString &s, bool allowEmptyEntries) { return DeprecatedStringList::split(DeprecatedString(separator), s, allowEmptyEntries); }
JSValue* JSXMLHttpRequestPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) { if (!thisObj->inherits(&JSXMLHttpRequest::info)) return throwError(exec, TypeError); JSXMLHttpRequest* request = static_cast<JSXMLHttpRequest*>(thisObj); ExceptionCode ec = 0; switch (id) { case JSXMLHttpRequest::Abort: request->m_impl->abort(); return jsUndefined(); case JSXMLHttpRequest::GetAllResponseHeaders: return jsStringOrUndefined(request->m_impl->getAllResponseHeaders()); case JSXMLHttpRequest::GetResponseHeader: if (args.size() < 1) return throwError(exec, SyntaxError, "Not enough arguments"); return jsStringOrNull(request->m_impl->getResponseHeader(args[0]->toString(exec))); case JSXMLHttpRequest::Open: { if (args.size() < 2) return throwError(exec, SyntaxError, "Not enough arguments"); String method = args[0]->toString(exec); Frame* frame = Window::retrieveActive(exec)->impl()->frame(); if (!frame) return jsUndefined(); KURL url = frame->loader()->completeURL(DeprecatedString(args[1]->toString(exec))); bool async = true; if (args.size() >= 3) async = args[2]->toBoolean(exec); if (args.size() >= 4 && !args[3]->isUndefined()) { String user = valueToStringWithNullCheck(exec, args[3]); if (args.size() >= 5 && !args[4]->isUndefined()) { String password = valueToStringWithNullCheck(exec, args[4]); request->m_impl->open(method, url, async, user, password, ec); } else request->m_impl->open(method, url, async, user, ec); } else request->m_impl->open(method, url, async, ec); setDOMException(exec, ec); return jsUndefined(); } case JSXMLHttpRequest::Send: { String body; if (args.size() >= 1) { if (args[0]->toObject(exec)->inherits(&JSDocument::info)) { Document* doc = static_cast<Document*>(static_cast<JSDocument*>(args[0]->toObject(exec))->impl()); body = doc->toString().deprecatedString(); } else { // converting certain values (like null) to object can set an exception if (exec->hadException()) exec->clearException(); else body = args[0]->toString(exec); } } request->m_impl->send(body, ec); setDOMException(exec, ec); return jsUndefined(); } case JSXMLHttpRequest::SetRequestHeader: if (args.size() < 2) return throwError(exec, SyntaxError, "Not enough arguments"); request->m_impl->setRequestHeader(args[0]->toString(exec), args[1]->toString(exec), ec); setDOMException(exec, ec); return jsUndefined(); case JSXMLHttpRequest::OverrideMIMEType: if (args.size() < 1) return throwError(exec, SyntaxError, "Not enough arguments"); request->m_impl->overrideMIMEType(args[0]->toString(exec)); return jsUndefined(); case JSXMLHttpRequest::AddEventListener: { Document* doc = request->m_impl->document(); if (!doc) return jsUndefined(); Frame* frame = doc->frame(); if (!frame) return jsUndefined(); JSUnprotectedEventListener* listener = KJS::Window::retrieveWindow(frame)->findOrCreateJSUnprotectedEventListener(args[1], true); if (!listener) return jsUndefined(); request->m_impl->addEventListener(args[0]->toString(exec), listener, args[2]->toBoolean(exec)); return jsUndefined(); } case JSXMLHttpRequest::RemoveEventListener: { Document* doc = request->m_impl->document(); if (!doc) return jsUndefined(); Frame* frame = doc->frame(); if (!frame) return jsUndefined(); JSUnprotectedEventListener* listener = KJS::Window::retrieveWindow(frame)->findOrCreateJSUnprotectedEventListener(args[1], true); if (!listener) return jsUndefined(); request->m_impl->removeEventListener(args[0]->toString(exec), listener, args[2]->toBoolean(exec)); return jsUndefined(); } case JSXMLHttpRequest::DispatchEvent: { bool result = request->m_impl->dispatchEvent(toEvent(args[0]), ec); setDOMException(exec, ec); return jsBoolean(result); } } return jsUndefined(); }
DeprecatedString StreamingTextDecoderICU::toUnicode(const char* chs, int len, bool flush) { ASSERT_ARG(len, len >= 0); if (!chs) return DeprecatedString(); if (len <= 0 && !flush) return ""; // Handle normal case. if (!m_atStart) return convert(chs, len, flush); // Check to see if we found a BOM. int numBufferedBytes = m_numBufferedBytes; int buf1Len = numBufferedBytes; int buf2Len = len; const unsigned char* buf1 = m_bufferedBytes; const unsigned char* buf2 = reinterpret_cast<const unsigned char*>(chs); unsigned char c1 = buf1Len ? (--buf1Len, *buf1++) : buf2Len ? (--buf2Len, *buf2++) : 0; unsigned char c2 = buf1Len ? (--buf1Len, *buf1++) : buf2Len ? (--buf2Len, *buf2++) : 0; unsigned char c3 = buf1Len ? (--buf1Len, *buf1++) : buf2Len ? (--buf2Len, *buf2++) : 0; int BOMLength = 0; if (c1 == 0xFF && c2 == 0xFE) { if (m_encoding != TextEncoding(UTF16Encoding, LittleEndian)) { releaseICUConverter(); m_encoding = TextEncoding(UTF16Encoding, LittleEndian); m_littleEndian = true; } BOMLength = 2; } else if (c1 == 0xFE && c2 == 0xFF) { if (m_encoding != TextEncoding(UTF16Encoding, BigEndian)) { releaseICUConverter(); m_encoding = TextEncoding(UTF16Encoding, BigEndian); m_littleEndian = false; } BOMLength = 2; } else if (c1 == 0xEF && c2 == 0xBB && c3 == 0xBF) { if (m_encoding != TextEncoding(UTF8Encoding)) { releaseICUConverter(); m_encoding = TextEncoding(UTF8Encoding); } BOMLength = 3; } // Handle case where we found a BOM. if (BOMLength != 0) { ASSERT(numBufferedBytes + len >= BOMLength); int skip = BOMLength - numBufferedBytes; m_numBufferedBytes = 0; m_atStart = false; return len == skip ? DeprecatedString("") : convert(chs + skip, len - skip, flush); } // Handle case where we know there is no BOM coming. const int bufferSize = sizeof(m_bufferedBytes); if (numBufferedBytes + len > bufferSize || flush) { m_atStart = false; if (numBufferedBytes == 0) { return convert(chs, len, flush); } unsigned char bufferedBytes[sizeof(m_bufferedBytes)]; memcpy(bufferedBytes, m_bufferedBytes, numBufferedBytes); m_numBufferedBytes = 0; return convert(bufferedBytes, numBufferedBytes, false) + convert(chs, len, flush); } // Continue to look for the BOM. memcpy(&m_bufferedBytes[numBufferedBytes], chs, len); m_numBufferedBytes += len; return ""; }
DeprecatedString SSLKeyGenerator::signedPublicKeyAndChallengeString(unsigned keySizeIndex, const DeprecatedString &challengeString, const KURL &url){return DeprecatedString();};