static char* cookieJarPath() { char* cookieJarPath = getenv("CURL_COOKIE_JAR_PATH"); if (cookieJarPath) return fastStrDup(cookieJarPath); #if OS(WINDOWS) char executablePath[MAX_PATH]; char appDataDirectory[MAX_PATH]; char cookieJarFullPath[MAX_PATH]; char cookieJarDirectory[MAX_PATH]; if (FAILED(::SHGetFolderPathA(0, CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE, 0, 0, appDataDirectory)) || FAILED(::GetModuleFileNameA(0, executablePath, MAX_PATH))) return fastStrDup("cookies.dat"); ::PathRemoveExtensionA(executablePath); LPSTR executableName = ::PathFindFileNameA(executablePath); sprintf_s(cookieJarDirectory, MAX_PATH, "%s/%s", appDataDirectory, executableName); sprintf_s(cookieJarFullPath, MAX_PATH, "%s/cookies.dat", cookieJarDirectory); if (::SHCreateDirectoryExA(0, cookieJarDirectory, 0) != ERROR_SUCCESS && ::GetLastError() != ERROR_FILE_EXISTS && ::GetLastError() != ERROR_ALREADY_EXISTS) return fastStrDup("cookies.dat"); return fastStrDup(cookieJarFullPath); #else return fastStrDup("cookies.dat"); #endif }
static char* cookieJarPath() { char* cookieJarPath = getenv("CURL_COOKIE_JAR_PATH"); if (cookieJarPath) return fastStrDup(cookieJarPath); return fastStrDup("cookies.dat"); }
void CurlDownload::init(CurlDownloadListener* listener, const URL& url) { if (!listener) return; MutexLocker locker(m_mutex); m_curlHandle = curl_easy_init(); String urlStr = url.string(); m_url = fastStrDup(urlStr.latin1().data()); curl_easy_setopt(m_curlHandle, CURLOPT_URL, m_url); curl_easy_setopt(m_curlHandle, CURLOPT_PRIVATE, this); curl_easy_setopt(m_curlHandle, CURLOPT_WRITEFUNCTION, writeCallback); curl_easy_setopt(m_curlHandle, CURLOPT_WRITEDATA, this); curl_easy_setopt(m_curlHandle, CURLOPT_HEADERFUNCTION, headerCallback); curl_easy_setopt(m_curlHandle, CURLOPT_WRITEHEADER, this); curl_easy_setopt(m_curlHandle, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(m_curlHandle, CURLOPT_MAXREDIRS, 10); curl_easy_setopt(m_curlHandle, CURLOPT_HTTPAUTH, CURLAUTH_ANY); const char* certPath = getenv("CURL_CA_BUNDLE_PATH"); if (certPath) curl_easy_setopt(m_curlHandle, CURLOPT_CAINFO, certPath); CURLSH* curlsh = ResourceHandleManager::sharedInstance()->getCurlShareHandle(); if (curlsh) curl_easy_setopt(m_curlHandle, CURLOPT_SHARE, curlsh); m_listener = listener; }
Collator::Collator(const char* locale, bool shouldSortLowercaseFirst) { UErrorCode status = U_ZERO_ERROR; { std::lock_guard<Lock> lock(cachedCollatorMutex); if (cachedCollator && localesMatch(cachedCollatorLocale, locale) && cachedCollatorShouldSortLowercaseFirst == shouldSortLowercaseFirst) { m_collator = cachedCollator; m_locale = cachedCollatorLocale; m_shouldSortLowercaseFirst = shouldSortLowercaseFirst; cachedCollator = nullptr; cachedCollatorLocale = nullptr; return; } } m_collator = ucol_open(resolveDefaultLocale(locale), &status); if (U_FAILURE(status)) { status = U_ZERO_ERROR; m_collator = ucol_open("", &status); // Fall back to Unicode Collation Algorithm. } ASSERT(U_SUCCESS(status)); ucol_setAttribute(m_collator, UCOL_CASE_FIRST, shouldSortLowercaseFirst ? UCOL_LOWER_FIRST : UCOL_UPPER_FIRST, &status); ASSERT(U_SUCCESS(status)); ucol_setAttribute(m_collator, UCOL_NORMALIZATION_MODE, UCOL_ON, &status); ASSERT(U_SUCCESS(status)); m_locale = locale ? fastStrDup(locale) : nullptr; m_shouldSortLowercaseFirst = shouldSortLowercaseFirst; }
void FontPlatformData::platformDataInit(const FontPlatformData& source) { m_harfbuzzFace = source.m_harfbuzzFace; m_scaledFont = 0; if (source.m_font && source.m_font != hashTableDeletedFontValue()) { m_font = FS_new_client(source.m_font, 0); m_name = fastStrDup(source.name()); bool ret = applyState(m_font); ASSERT_UNUSED(ret, ret); } else m_font = source.m_font; }
const FontPlatformData& FontPlatformData::platformDataAssign(const FontPlatformData& other) { m_harfbuzzFace = other.m_harfbuzzFace; m_scaledFont = 0; if (other.m_font && other.m_font != hashTableDeletedFontValue()) { m_font = FS_new_client(other.m_font, 0); fastFree(m_name); m_name = fastStrDup(other.name()); bool ret = applyState(m_font); ASSERT_UNUSED(ret, ret); } else m_font = other.m_font; return *this; }
void CurlDownload::init(CurlDownloadListener* listener, const URL& url) { if (!listener) return; MutexLocker locker(m_mutex); m_curlHandle = curl_easy_init(); String urlStr = url.string(); m_url = fastStrDup(urlStr.latin1().data()); #ifndef NDEBUG if (getenv("DEBUG_CURL")) curl_easy_setopt(m_curlHandle, CURLOPT_VERBOSE, 1); #endif // Fifth handles certs differently; ignore CA checks. curl_easy_setopt(m_curlHandle, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(m_curlHandle, CURLOPT_SSL_VERIFYHOST, 2L); curl_easy_setopt(m_curlHandle, CURLOPT_URL, m_url); curl_easy_setopt(m_curlHandle, CURLOPT_PRIVATE, this); curl_easy_setopt(m_curlHandle, CURLOPT_WRITEFUNCTION, writeCallback); curl_easy_setopt(m_curlHandle, CURLOPT_WRITEDATA, this); curl_easy_setopt(m_curlHandle, CURLOPT_HEADERFUNCTION, headerCallback); curl_easy_setopt(m_curlHandle, CURLOPT_WRITEHEADER, this); curl_easy_setopt(m_curlHandle, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(m_curlHandle, CURLOPT_MAXREDIRS, 10); curl_easy_setopt(m_curlHandle, CURLOPT_HTTPAUTH, CURLAUTH_ANY); // Youtube requires an insecure SSL cipher that curl disables by default. // Enable it only for those sites to stay secure. if (url.host().endsWith("googlevideo.com") || url.host().endsWith("youtube.com")) curl_easy_setopt(m_curlHandle, CURLOPT_SSL_CIPHER_LIST, "DEFAULT"); // TODO warning: download certs *aren't* currently checked! Requires SSLHandle reorg. CURLSH* curlsh = ResourceHandleManager::sharedInstance()->getCurlShareHandle(); if (curlsh) curl_easy_setopt(m_curlHandle, CURLOPT_SHARE, curlsh); m_listener = listener; }
FontPlatformData::FontPlatformData(FILECHAR* name, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, TextOrientation textOrientation, FontWidthVariant widthVariant) : m_syntheticBold(syntheticBold) , m_syntheticOblique(syntheticOblique) , m_orientation(orientation) , m_textOrientation(textOrientation) , m_size(size) , m_widthVariant(widthVariant) , m_font(0) , m_name(fastStrDup(name)) , m_scaledFont(0) , m_harfbuzzFace() , m_isColorBitmapFont(false) { ASSERT(name); m_font = FS_new_client(BlackBerry::Platform::Graphics::getIType(), 0); ASSERT(m_font); applyState(m_font); }
void TextCodecICU::registerCodecs(TextCodecRegistrar registrar) { // See comment above in registerEncodingNames. UErrorCode error = U_ZERO_ERROR; const char* canonicalConverterName = ucnv_getCanonicalName("ISO-8859-8-I", "IANA", &error); ASSERT(U_SUCCESS(error)); registrar("ISO-8859-8-I", create, canonicalConverterName); int32_t numConverters = ucnv_countAvailable(); for (int32_t i = 0; i < numConverters; ++i) { canonicalConverterName = ucnv_getAvailableName(i); error = U_ZERO_ERROR; const char* webStandardName = ucnv_getStandardName(canonicalConverterName, "MIME", &error); if (!U_SUCCESS(error) || !webStandardName) { error = U_ZERO_ERROR; webStandardName = ucnv_getStandardName(canonicalConverterName, "IANA", &error); if (!U_SUCCESS(error) || !webStandardName) continue; } // Don't register codecs for overridden encodings. if (strcmp(webStandardName, "GB2312") == 0 || strcmp(webStandardName, "GB_2312-80") == 0 || strcmp(webStandardName, "KSC_5601") == 0 || strcmp(webStandardName, "EUC-KR") == 0 || strcmp(webStandardName, "cp1363") == 0 || strcasecmp(webStandardName, "iso-8859-9") == 0 || strcmp(webStandardName, "TIS-620") == 0) continue; registrar(webStandardName, create, fastStrDup(canonicalConverterName)); } // These encodings currently don't have standard names, so we need to register encoders manually. // FIXME: Is there a good way to determine the most up to date variant programmatically? registrar("windows-874", create, "windows-874-2000"); registrar("windows-949", create, "windows-949-2000"); }
void PluginStream::startStream() { ASSERT(m_streamState == StreamBeforeStarted); const KURL& responseURL = m_resourceResponse.url(); // Some plugins (Flash) expect that javascript URLs are passed back decoded as this is the // format used when requesting the URL. if (protocolIsJavaScript(responseURL)) m_stream.url = fastStrDup(decodeURLEscapeSequences(responseURL.string()).utf8().data()); else m_stream.url = fastStrDup(responseURL.string().utf8().data()); CString mimeTypeStr = m_resourceResponse.mimeType().utf8(); long long expectedContentLength = m_resourceResponse.expectedContentLength(); if (m_resourceResponse.isHTTP()) { Vector<UChar> stringBuilder; String separator(": "); String statusLine = makeString("HTTP ", String::number(m_resourceResponse.httpStatusCode()), " OK\n"); stringBuilder.append(statusLine.characters(), statusLine.length()); HTTPHeaderMap::const_iterator end = m_resourceResponse.httpHeaderFields().end(); for (HTTPHeaderMap::const_iterator it = m_resourceResponse.httpHeaderFields().begin(); it != end; ++it) { stringBuilder.append(it->first.characters(), it->first.length()); stringBuilder.append(separator.characters(), separator.length()); stringBuilder.append(it->second.characters(), it->second.length()); stringBuilder.append('\n'); } m_headers = String::adopt(stringBuilder).utf8(); // If the content is encoded (most likely compressed), then don't send its length to the plugin, // which is only interested in the decoded length, not yet known at the moment. // <rdar://problem/4470599> tracks a request for -[NSURLResponse expectedContentLength] to incorporate this logic. String contentEncoding = m_resourceResponse.httpHeaderField("Content-Encoding"); if (!contentEncoding.isNull() && contentEncoding != "identity") expectedContentLength = -1; } m_stream.headers = m_headers.data(); m_stream.pdata = 0; m_stream.ndata = this; m_stream.end = max(expectedContentLength, 0LL); m_stream.lastmodified = m_resourceResponse.lastModifiedDate(); m_stream.notifyData = m_notifyData; m_transferMode = NP_NORMAL; m_offset = 0; m_reason = WebReasonNone; // Protect the stream if destroystream is called from within the newstream handler RefPtr<PluginStream> protect(this); // calling into a plug-in could result in re-entrance if the plug-in yields // control to the system (rdar://5744899). prevent this by deferring further // loading while calling into the plug-in. if (m_loader) m_loader->setDefersLoading(true); NPError npErr = m_pluginFuncs->newstream(m_instance, (NPMIMEType)mimeTypeStr.data(), &m_stream, false, &m_transferMode); if (m_loader) m_loader->setDefersLoading(false); // If the stream was destroyed in the call to newstream we return if (m_reason != WebReasonNone) return; if (npErr != NPERR_NO_ERROR) { cancelAndDestroyStream(npErr); return; } m_streamState = StreamStarted; if (m_transferMode == NP_NORMAL) return; m_path = openTemporaryFile("WKP", m_tempFileHandle); // Something went wrong, cancel loading the stream if (!isHandleValid(m_tempFileHandle)) cancelAndDestroyStream(NPRES_NETWORK_ERR); }