void HTMLBodyElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style)
{
    if (name == backgroundAttr) {
        String url = stripLeadingAndTrailingHTMLSpaces(value);
        if (!url.isEmpty()) {
            RefPtrWillBeRawPtr<CSSImageValue> imageValue = CSSImageValue::create(url, document().completeURL(url));
            imageValue->setInitiator(localName());
            imageValue->setReferrer(Referrer(document().outgoingReferrer(), document().referrerPolicy()));
            style->setProperty(CSSProperty(CSSPropertyBackgroundImage, imageValue.release()));
        }
    } else if (name == marginwidthAttr || name == leftmarginAttr) {
        addHTMLLengthToStyle(style, CSSPropertyMarginRight, value);
        addHTMLLengthToStyle(style, CSSPropertyMarginLeft, value);
    } else if (name == marginheightAttr || name == topmarginAttr) {
        addHTMLLengthToStyle(style, CSSPropertyMarginBottom, value);
        addHTMLLengthToStyle(style, CSSPropertyMarginTop, value);
    } else if (name == bgcolorAttr) {
        addHTMLColorToStyle(style, CSSPropertyBackgroundColor, value);
    } else if (name == textAttr) {
        addHTMLColorToStyle(style, CSSPropertyColor, value);
    } else if (name == bgpropertiesAttr) {
        if (equalIgnoringCase(value, "fixed")) {
            UseCounter::count(document(), UseCounter::BgPropertiesFixed);
            addPropertyToPresentationAttributeStyle(style, CSSPropertyBackgroundAttachment, CSSValueFixed);
        }
    } else
        HTMLElement::collectStyleForPresentationAttribute(name, value, style);
}
コード例 #2
0
ファイル: WebURLRequest.cpp プロジェクト: coinpayee/blink
void WebURLRequest::setHTTPReferrer(const WebString& referrer, WebReferrerPolicy referrerPolicy)
{
    if (referrer.isEmpty())
        m_private->m_resourceRequest->clearHTTPReferrer();
    else
        m_private->m_resourceRequest->setHTTPReferrer(Referrer(referrer, static_cast<ReferrerPolicy>(referrerPolicy)));
}
void FrameFetchContext::addAdditionalRequestHeaders(Document* document, ResourceRequest& request, FetchResourceType type)
{
    bool isMainResource = type == FetchMainResource;
    if (!isMainResource) {
        String outgoingReferrer;
        String outgoingOrigin;
        if (request.httpReferrer().isNull()) {
            outgoingReferrer = document->outgoingReferrer();
            outgoingOrigin = document->outgoingOrigin();
        } else {
            outgoingReferrer = request.httpReferrer();
            outgoingOrigin = SecurityOrigin::createFromString(outgoingReferrer)->toString();
        }

        outgoingReferrer = SecurityPolicy::generateReferrerHeader(document->referrerPolicy(), request.url(), outgoingReferrer);
        if (outgoingReferrer.isEmpty())
            request.clearHTTPReferrer();
        else if (!request.httpReferrer())
            request.setHTTPReferrer(Referrer(outgoingReferrer, document->referrerPolicy()));

        request.addHTTPOriginIfNeeded(AtomicString(outgoingOrigin));
    }

    // The remaining modifications are only necessary for HTTP and HTTPS.
    if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily())
        return;

    m_frame->loader().applyUserAgent(request);
}
コード例 #4
0
void StyleRuleImport::setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CSSStyleSheetResource* cachedStyleSheet)
{
    if (m_styleSheet)
        m_styleSheet->clearOwnerRule();

    CSSParserContext context = m_parentStyleSheet ? m_parentStyleSheet->parserContext() : strictCSSParserContext();
    context.setCharset(charset);
    Document* document = m_parentStyleSheet ? m_parentStyleSheet->singleOwnerDocument() : 0;
    if (!baseURL.isNull()) {
        context.setBaseURL(baseURL);
        if (document)
            context.setReferrer(Referrer(baseURL.strippedForUseAsReferrer(), document->referrerPolicy()));
    }

    m_styleSheet = StyleSheetContents::create(this, href, context);

    m_styleSheet->parseAuthorStyleSheet(cachedStyleSheet, document ? document->securityOrigin() : 0);

    m_loading = false;

    if (m_parentStyleSheet) {
        m_parentStyleSheet->notifyLoadedSheet(cachedStyleSheet);
        m_parentStyleSheet->checkLoaded();
    }
}
コード例 #5
0
FetchRequestData::FetchRequestData()
    : m_method(HTTPNames::GET)
    , m_headerList(FetchHeaderList::create())
    , m_unsafeRequestFlag(false)
    , m_context(WebURLRequest::RequestContextUnspecified)
    , m_sameOriginDataURLFlag(false)
    , m_referrer(Referrer(clientReferrerString(), ReferrerPolicyDefault))
    , m_mode(WebURLRequest::FetchRequestModeNoCORS)
    , m_credentials(WebURLRequest::FetchCredentialsModeOmit)
    , m_redirect(WebURLRequest::FetchRedirectModeFollow)
    , m_responseTainting(BasicTainting)
{
}
コード例 #6
0
PrivateD3D10ProviderData::PrivateD3D10ProviderData(DeviceManagerD3D10 *deviceManager, ProviderD3D10Impl *providerD3D10, ProviderBinding *binding)
    : m_providerBinding(Referrer(GetThis()), binding)
    , m_d3dDeviceManager(deviceManager)
    , m_provider(providerD3D10)
    , m_needFlagsRefresh(false)
#ifndef NDEBUG
    , m_lockedForWrite(false)
    , m_lockedForReadCount(0)
#endif
{
    binding->GetWatch(&m_providerBindingWatch);
    m_d3dDeviceManager->AddListener(this);
}
コード例 #7
0
void WorkerThreadableLoader::MainThreadBridge::mainThreadCreateLoader(ExecutionContext* context, MainThreadBridge* thisPtr, PassOwnPtr<CrossThreadResourceRequestData> requestData, ThreadableLoaderOptions options, ResourceLoaderOptions resourceLoaderOptions, const String& outgoingReferrer)
{
    ASSERT(isMainThread());
    Document* document = toDocument(context);

    OwnPtr<ResourceRequest> request(ResourceRequest::adopt(requestData));
    request->setHTTPReferrer(Referrer(outgoingReferrer, ReferrerPolicyDefault));
    resourceLoaderOptions.requestInitiatorContext = WorkerContext;
    thisPtr->m_mainThreadLoader = DocumentThreadableLoader::create(*document, thisPtr, *request, options, resourceLoaderOptions);
    if (!thisPtr->m_mainThreadLoader) {
        // DocumentThreadableLoader::create may return 0 when the document loader has been already changed.
        thisPtr->didFail(ResourceError(errorDomainBlinkInternal, 0, request->url().string(), "Can't create DocumentThreadableLoader"));
    }
}
コード例 #8
0
FetchRequestData* FetchRequestData::create(ScriptState* scriptState, const WebServiceWorkerRequest& webRequest)
{
    FetchRequestData* request = FetchRequestData::create();
    request->m_url = webRequest.url();
    request->m_method = webRequest.method();
    for (HTTPHeaderMap::const_iterator it = webRequest.headers().begin(); it != webRequest.headers().end(); ++it)
        request->m_headerList->append(it->key, it->value);
    if (webRequest.blobDataHandle())
        request->setBuffer(new BodyStreamBuffer(scriptState, FetchBlobDataConsumerHandle::create(scriptState->getExecutionContext(), webRequest.blobDataHandle())));
    request->setContext(webRequest.requestContext());
    request->setReferrer(Referrer(webRequest.referrerUrl().string(), static_cast<ReferrerPolicy>(webRequest.referrerPolicy())));
    request->setMode(webRequest.mode());
    request->setCredentials(webRequest.credentialsMode());
    request->setRedirect(webRequest.redirectMode());
    request->setMIMEType(request->m_headerList->extractMIMEType());
    return request;
}
コード例 #9
0
ファイル: CSSImageValue.cpp プロジェクト: coinpayee/blink
StyleFetchedImage* CSSImageValue::cachedImage(ResourceFetcher* fetcher, const ResourceLoaderOptions& options)
{
    ASSERT(fetcher);

    if (!m_accessedImage) {
        m_accessedImage = true;

        FetchRequest request(ResourceRequest(m_absoluteURL), m_initiatorName.isEmpty() ? FetchInitiatorTypeNames::css : m_initiatorName, options);
        if (!m_referrer.isEmpty())
            request.mutableResourceRequest().setHTTPReferrer(Referrer(m_referrer, ReferrerPolicyDefault));

        if (options.corsEnabled == IsCORSEnabled)
            request.setCrossOriginAccessControl(fetcher->document()->securityOrigin(), options.allowCredentials, options.credentialsRequested);

        if (ResourcePtr<ImageResource> cachedImage = fetcher->fetchImage(request))
            m_image = StyleFetchedImage::create(cachedImage.get());
    }

    return (m_image && m_image->isImageResource()) ? toStyleFetchedImage(m_image) : 0;
}
コード例 #10
0
void WebServiceWorkerRequest::setReferrer(const WebString& referrer, WebReferrerPolicy referrerPolicy)
{
    m_private->m_referrer = Referrer(referrer, static_cast<ReferrerPolicy>(referrerPolicy));
}
コード例 #11
0
TEST(ResourceRequestTest, CrossThreadResourceRequestData) {
  ResourceRequest original;
  original.setURL(KURL(ParsedURLString, "http://www.example.com/test.htm"));
  original.setCachePolicy(WebCachePolicy::UseProtocolCachePolicy);
  original.setTimeoutInterval(10);
  original.setFirstPartyForCookies(
      KURL(ParsedURLString, "http://www.example.com/first_party.htm"));
  original.setRequestorOrigin(SecurityOrigin::create(
      KURL(ParsedURLString, "http://www.example.com/first_party.htm")));
  original.setHTTPMethod(HTTPNames::GET);
  original.setHTTPHeaderField(AtomicString("Foo"), AtomicString("Bar"));
  original.setHTTPHeaderField(AtomicString("Piyo"), AtomicString("Fuga"));
  original.setPriority(ResourceLoadPriorityLow, 20);

  RefPtr<EncodedFormData> originalBody(EncodedFormData::create("Test Body"));
  original.setHTTPBody(originalBody);
  original.setAllowStoredCredentials(false);
  original.setReportUploadProgress(false);
  original.setHasUserGesture(false);
  original.setDownloadToFile(false);
  original.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::None);
  original.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS);
  original.setFetchCredentialsMode(
      WebURLRequest::FetchCredentialsModeSameOrigin);
  original.setRequestorID(30);
  original.setRequestorProcessID(40);
  original.setAppCacheHostID(50);
  original.setRequestContext(WebURLRequest::RequestContextAudio);
  original.setFrameType(WebURLRequest::FrameTypeNested);
  original.setHTTPReferrer(
      Referrer("http://www.example.com/referrer.htm", ReferrerPolicyDefault));

  EXPECT_STREQ("http://www.example.com/test.htm",
               original.url().getString().utf8().data());
  EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, original.getCachePolicy());
  EXPECT_EQ(10, original.timeoutInterval());
  EXPECT_STREQ("http://www.example.com/first_party.htm",
               original.firstPartyForCookies().getString().utf8().data());
  EXPECT_STREQ("www.example.com",
               original.requestorOrigin()->host().utf8().data());
  EXPECT_STREQ("GET", original.httpMethod().utf8().data());
  EXPECT_STREQ("Bar", original.httpHeaderFields().get("Foo").utf8().data());
  EXPECT_STREQ("Fuga", original.httpHeaderFields().get("Piyo").utf8().data());
  EXPECT_EQ(ResourceLoadPriorityLow, original.priority());
  EXPECT_STREQ("Test Body",
               original.httpBody()->flattenToString().utf8().data());
  EXPECT_FALSE(original.allowStoredCredentials());
  EXPECT_FALSE(original.reportUploadProgress());
  EXPECT_FALSE(original.hasUserGesture());
  EXPECT_FALSE(original.downloadToFile());
  EXPECT_EQ(WebURLRequest::SkipServiceWorker::None,
            original.skipServiceWorker());
  EXPECT_EQ(WebURLRequest::FetchRequestModeCORS, original.fetchRequestMode());
  EXPECT_EQ(WebURLRequest::FetchCredentialsModeSameOrigin,
            original.fetchCredentialsMode());
  EXPECT_EQ(30, original.requestorID());
  EXPECT_EQ(40, original.requestorProcessID());
  EXPECT_EQ(50, original.appCacheHostID());
  EXPECT_EQ(WebURLRequest::RequestContextAudio, original.requestContext());
  EXPECT_EQ(WebURLRequest::FrameTypeNested, original.frameType());
  EXPECT_STREQ("http://www.example.com/referrer.htm",
               original.httpReferrer().utf8().data());
  EXPECT_EQ(ReferrerPolicyDefault, original.getReferrerPolicy());

  std::unique_ptr<CrossThreadResourceRequestData> data1(original.copyData());
  ResourceRequest copy1(data1.get());

  EXPECT_STREQ("http://www.example.com/test.htm",
               copy1.url().getString().utf8().data());
  EXPECT_EQ(WebCachePolicy::UseProtocolCachePolicy, copy1.getCachePolicy());
  EXPECT_EQ(10, copy1.timeoutInterval());
  EXPECT_STREQ("http://www.example.com/first_party.htm",
               copy1.firstPartyForCookies().getString().utf8().data());
  EXPECT_STREQ("www.example.com",
               copy1.requestorOrigin()->host().utf8().data());
  EXPECT_STREQ("GET", copy1.httpMethod().utf8().data());
  EXPECT_STREQ("Bar", copy1.httpHeaderFields().get("Foo").utf8().data());
  EXPECT_EQ(ResourceLoadPriorityLow, copy1.priority());
  EXPECT_STREQ("Test Body", copy1.httpBody()->flattenToString().utf8().data());
  EXPECT_FALSE(copy1.allowStoredCredentials());
  EXPECT_FALSE(copy1.reportUploadProgress());
  EXPECT_FALSE(copy1.hasUserGesture());
  EXPECT_FALSE(copy1.downloadToFile());
  EXPECT_EQ(WebURLRequest::SkipServiceWorker::None, copy1.skipServiceWorker());
  EXPECT_EQ(WebURLRequest::FetchRequestModeCORS, copy1.fetchRequestMode());
  EXPECT_EQ(WebURLRequest::FetchCredentialsModeSameOrigin,
            copy1.fetchCredentialsMode());
  EXPECT_EQ(30, copy1.requestorID());
  EXPECT_EQ(40, copy1.requestorProcessID());
  EXPECT_EQ(50, copy1.appCacheHostID());
  EXPECT_EQ(WebURLRequest::RequestContextAudio, copy1.requestContext());
  EXPECT_EQ(WebURLRequest::FrameTypeNested, copy1.frameType());
  EXPECT_STREQ("http://www.example.com/referrer.htm",
               copy1.httpReferrer().utf8().data());
  EXPECT_EQ(ReferrerPolicyDefault, copy1.getReferrerPolicy());

  copy1.setAllowStoredCredentials(true);
  copy1.setReportUploadProgress(true);
  copy1.setHasUserGesture(true);
  copy1.setDownloadToFile(true);
  copy1.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All);
  copy1.setFetchRequestMode(WebURLRequest::FetchRequestModeNoCORS);
  copy1.setFetchCredentialsMode(WebURLRequest::FetchCredentialsModeInclude);

  std::unique_ptr<CrossThreadResourceRequestData> data2(copy1.copyData());
  ResourceRequest copy2(data2.get());
  EXPECT_TRUE(copy2.allowStoredCredentials());
  EXPECT_TRUE(copy2.reportUploadProgress());
  EXPECT_TRUE(copy2.hasUserGesture());
  EXPECT_TRUE(copy2.downloadToFile());
  EXPECT_EQ(WebURLRequest::SkipServiceWorker::All, copy2.skipServiceWorker());
  EXPECT_EQ(WebURLRequest::FetchRequestModeNoCORS, copy1.fetchRequestMode());
  EXPECT_EQ(WebURLRequest::FetchCredentialsModeInclude,
            copy1.fetchCredentialsMode());
}
コード例 #12
0
void WebURLRequest::setHTTPReferrer(const WebString& referrer, WebReferrerPolicy referrerPolicy)
{
    m_private->m_resourceRequest->setHTTPReferrer(Referrer(referrer, static_cast<ReferrerPolicy>(referrerPolicy)));
}
コード例 #13
0
ファイル: RequestInit.cpp プロジェクト: dstockwell/blink
RequestInit::RequestInit(ExecutionContext* context, const Dictionary& options, ExceptionState& exceptionState)
    : opaque(false), isReferrerSet(false)
{
    bool areAnyMembersSet = false;

    areAnyMembersSet = DictionaryHelper::get(options, "method", method) || areAnyMembersSet;
    areAnyMembersSet = DictionaryHelper::get(options, "headers", headers) || areAnyMembersSet;
    if (!headers) {
        Vector<Vector<String>> headersVector;
        if (DictionaryHelper::get(options, "headers", headersVector, exceptionState)) {
            headers = Headers::create(headersVector, exceptionState);
            areAnyMembersSet = true;
        } else {
            areAnyMembersSet = DictionaryHelper::get(options, "headers", headersDictionary) || areAnyMembersSet;
        }
    }
    areAnyMembersSet = DictionaryHelper::get(options, "mode", mode) || areAnyMembersSet;
    areAnyMembersSet = DictionaryHelper::get(options, "credentials", credentials) || areAnyMembersSet;
    areAnyMembersSet = DictionaryHelper::get(options, "redirect", redirect) || areAnyMembersSet;
    AtomicString referrerString;
    bool isReferrerStringSet = DictionaryHelper::get(options, "referrer", referrerString);
    areAnyMembersSet = areAnyMembersSet || isReferrerStringSet;
    areAnyMembersSet = DictionaryHelper::get(options, "integrity", integrity) || areAnyMembersSet;

    v8::Local<v8::Value> v8Body;
    bool isBodySet = DictionaryHelper::get(options, "body", v8Body);
    areAnyMembersSet = areAnyMembersSet || isBodySet;

    if (areAnyMembersSet) {
        // If any of init's members are present, unset request's
        // omit-Origin-header flag, set request's referrer to "client",
        // and request's referrer policy to the empty string.
        //
        // We need to use "about:client" instead of |clientReferrerString|,
        // because "about:client" => |clientReferrerString| conversion is done
        // in Request::createRequestWithRequestOrString.
        referrer = Referrer("about:client", ReferrerPolicyDefault);
        if (isReferrerStringSet)
            referrer.referrer = referrerString;
        isReferrerSet = true;
    }

    if (!isBodySet || v8Body->IsUndefined() || v8Body->IsNull())
        return;
    v8::Isolate* isolate = toIsolate(context);
    if (v8Body->IsArrayBuffer()) {
        body = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(v8::Local<v8::Object>::Cast(v8Body)));
    } else if (v8Body->IsArrayBufferView()) {
        body = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(v8::Local<v8::Object>::Cast(v8Body)));
    } else if (V8Blob::hasInstance(v8Body, isolate)) {
        RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8::Local<v8::Object>::Cast(v8Body))->blobDataHandle();
        contentType = blobDataHandle->type();
        body = FetchBlobDataConsumerHandle::create(context, blobDataHandle.release());
    } else if (V8FormData::hasInstance(v8Body, isolate)) {
        FormData* domFormData = V8FormData::toImpl(v8::Local<v8::Object>::Cast(v8Body));
        opaque = domFormData->opaque();

        RefPtr<EncodedFormData> formData = domFormData->encodeMultiPartFormData();
        // Here we handle formData->boundary() as a C-style string. See
        // FormDataEncoder::generateUniqueBoundaryString.
        contentType = AtomicString("multipart/form-data; boundary=", AtomicString::ConstructFromLiteral) + formData->boundary().data();
        body = FetchFormDataConsumerHandle::create(context, formData.release());
    } else if (v8Body->IsString()) {
        contentType = "text/plain;charset=UTF-8";
        body = FetchFormDataConsumerHandle::create(toUSVString(isolate, v8Body, exceptionState));
    }
}
コード例 #14
0
void WebHistoryItem::setReferrer(const WebString& referrer, WebReferrerPolicy referrerPolicy)
{
    m_private->setReferrer(Referrer(referrer, static_cast<ReferrerPolicy>(referrerPolicy)));
}
コード例 #15
0
TEST(ResourceRequestTest, CrossThreadResourceRequestData)
{
    ResourceRequest original;
    original.setURL(KURL(ParsedURLString, "http://www.example.com/test.htm"));
    original.setCachePolicy(UseProtocolCachePolicy);
    original.setTimeoutInterval(10);
    original.setFirstPartyForCookies(KURL(ParsedURLString, "http://www.example.com/first_party.htm"));
    original.setHTTPMethod(AtomicString("GET", AtomicString::ConstructFromLiteral));
    original.setHTTPHeaderField(AtomicString("Foo"), AtomicString("Bar"));
    original.setHTTPHeaderField(AtomicString("Piyo"), AtomicString("Fuga"));
    original.setPriority(ResourceLoadPriorityLow, 20);

    RefPtr<FormData> originalBody(FormData::create("Test Body"));
    original.setHTTPBody(originalBody);
    original.setAllowStoredCredentials(false);
    original.setReportUploadProgress(false);
    original.setHasUserGesture(false);
    original.setDownloadToFile(false);
    original.setSkipServiceWorker(false);
    original.setFetchRequestMode(WebURLRequest::FetchRequestModeCORS);
    original.setFetchCredentialsMode(WebURLRequest::FetchCredentialsModeSameOrigin);
    original.setRequestorID(30);
    original.setRequestorProcessID(40);
    original.setAppCacheHostID(50);
    original.setRequestContext(WebURLRequest::RequestContextAudio);
    original.setFrameType(WebURLRequest::FrameTypeNested);
    original.setHTTPReferrer(Referrer("http://www.example.com/referrer.htm", ReferrerPolicyDefault));

    EXPECT_STREQ("http://www.example.com/test.htm", original.url().string().utf8().data());
    EXPECT_EQ(UseProtocolCachePolicy, original.cachePolicy());
    EXPECT_EQ(10, original.timeoutInterval());
    EXPECT_STREQ("http://www.example.com/first_party.htm", original.firstPartyForCookies().string().utf8().data());
    EXPECT_STREQ("GET", original.httpMethod().utf8().data());
    EXPECT_STREQ("Bar", original.httpHeaderFields().get("Foo").utf8().data());
    EXPECT_STREQ("Fuga", original.httpHeaderFields().get("Piyo").utf8().data());
    EXPECT_EQ(ResourceLoadPriorityLow, original.priority());
    EXPECT_STREQ("Test Body", original.httpBody()->flattenToString().utf8().data());
    EXPECT_FALSE(original.allowStoredCredentials());
    EXPECT_FALSE(original.reportUploadProgress());
    EXPECT_FALSE(original.hasUserGesture());
    EXPECT_FALSE(original.downloadToFile());
    EXPECT_FALSE(original.skipServiceWorker());
    EXPECT_EQ(WebURLRequest::FetchRequestModeCORS, original.fetchRequestMode());
    EXPECT_EQ(WebURLRequest::FetchCredentialsModeSameOrigin, original.fetchCredentialsMode());
    EXPECT_EQ(30, original.requestorID());
    EXPECT_EQ(40, original.requestorProcessID());
    EXPECT_EQ(50, original.appCacheHostID());
    EXPECT_EQ(WebURLRequest::RequestContextAudio, original.requestContext());
    EXPECT_EQ(WebURLRequest::FrameTypeNested, original.frameType());
    EXPECT_STREQ("http://www.example.com/referrer.htm", original.httpReferrer().utf8().data());
    EXPECT_EQ(ReferrerPolicyDefault, original.referrerPolicy());

    OwnPtr<CrossThreadResourceRequestData> data1(original.copyData());
    OwnPtr<ResourceRequest> copy1(ResourceRequest::adopt(data1.release()));

    EXPECT_STREQ("http://www.example.com/test.htm", copy1->url().string().utf8().data());
    EXPECT_EQ(UseProtocolCachePolicy, copy1->cachePolicy());
    EXPECT_EQ(10, copy1->timeoutInterval());
    EXPECT_STREQ("http://www.example.com/first_party.htm", copy1->firstPartyForCookies().string().utf8().data());
    EXPECT_STREQ("GET", copy1->httpMethod().utf8().data());
    EXPECT_STREQ("Bar", copy1->httpHeaderFields().get("Foo").utf8().data());
    EXPECT_EQ(ResourceLoadPriorityLow, copy1->priority());
    EXPECT_STREQ("Test Body", copy1->httpBody()->flattenToString().utf8().data());
    EXPECT_FALSE(copy1->allowStoredCredentials());
    EXPECT_FALSE(copy1->reportUploadProgress());
    EXPECT_FALSE(copy1->hasUserGesture());
    EXPECT_FALSE(copy1->downloadToFile());
    EXPECT_FALSE(copy1->skipServiceWorker());
    EXPECT_EQ(WebURLRequest::FetchRequestModeCORS, copy1->fetchRequestMode());
    EXPECT_EQ(WebURLRequest::FetchCredentialsModeSameOrigin, copy1->fetchCredentialsMode());
    EXPECT_EQ(30, copy1->requestorID());
    EXPECT_EQ(40, copy1->requestorProcessID());
    EXPECT_EQ(50, copy1->appCacheHostID());
    EXPECT_EQ(WebURLRequest::RequestContextAudio, copy1->requestContext());
    EXPECT_EQ(WebURLRequest::FrameTypeNested, copy1->frameType());
    EXPECT_STREQ("http://www.example.com/referrer.htm", copy1->httpReferrer().utf8().data());
    EXPECT_EQ(ReferrerPolicyDefault, copy1->referrerPolicy());

    copy1->setAllowStoredCredentials(true);
    copy1->setReportUploadProgress(true);
    copy1->setHasUserGesture(true);
    copy1->setDownloadToFile(true);
    copy1->setSkipServiceWorker(true);
    copy1->setFetchRequestMode(WebURLRequest::FetchRequestModeNoCORS);
    copy1->setFetchCredentialsMode(WebURLRequest::FetchCredentialsModeInclude);

    OwnPtr<CrossThreadResourceRequestData> data2(copy1->copyData());
    OwnPtr<ResourceRequest> copy2(ResourceRequest::adopt(data2.release()));
    EXPECT_TRUE(copy2->allowStoredCredentials());
    EXPECT_TRUE(copy2->reportUploadProgress());
    EXPECT_TRUE(copy2->hasUserGesture());
    EXPECT_TRUE(copy2->downloadToFile());
    EXPECT_TRUE(copy2->skipServiceWorker());
    EXPECT_EQ(WebURLRequest::FetchRequestModeNoCORS, copy1->fetchRequestMode());
    EXPECT_EQ(WebURLRequest::FetchCredentialsModeInclude, copy1->fetchCredentialsMode());
}
コード例 #16
0
void HTMLTableElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style)
{
    if (name == widthAttr)
        addHTMLLengthToStyle(style, CSSPropertyWidth, value);
    else if (name == heightAttr)
        addHTMLLengthToStyle(style, CSSPropertyHeight, value);
    else if (name == borderAttr)
        addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidth, parseBorderWidthAttribute(value), CSSPrimitiveValue::CSS_PX);
    else if (name == bordercolorAttr) {
        if (!value.isEmpty())
            addHTMLColorToStyle(style, CSSPropertyBorderColor, value);
    } else if (name == bgcolorAttr)
        addHTMLColorToStyle(style, CSSPropertyBackgroundColor, value);
    else if (name == backgroundAttr) {
        String url = stripLeadingAndTrailingHTMLSpaces(value);
        if (!url.isEmpty()) {
            RefPtrWillBeRawPtr<CSSImageValue> imageValue = CSSImageValue::create(url, document().completeURL(url));
            imageValue->setReferrer(Referrer(document().outgoingReferrer(), document().referrerPolicy()));
            style->setProperty(CSSProperty(CSSPropertyBackgroundImage, imageValue.release()));
        }
    } else if (name == valignAttr) {
        if (!value.isEmpty())
            addPropertyToPresentationAttributeStyle(style, CSSPropertyVerticalAlign, value);
    } else if (name == cellspacingAttr) {
        if (!value.isEmpty())
            addHTMLLengthToStyle(style, CSSPropertyBorderSpacing, value);
    } else if (name == vspaceAttr) {
        UseCounter::countDeprecation(document(), UseCounter::HTMLTableElementVspace);
        addHTMLLengthToStyle(style, CSSPropertyMarginTop, value);
        addHTMLLengthToStyle(style, CSSPropertyMarginBottom, value);
    } else if (name == hspaceAttr) {
        UseCounter::countDeprecation(document(), UseCounter::HTMLTableElementHspace);
        addHTMLLengthToStyle(style, CSSPropertyMarginLeft, value);
        addHTMLLengthToStyle(style, CSSPropertyMarginRight, value);
    } else if (name == alignAttr) {
        if (!value.isEmpty()) {
            if (equalIgnoringCase(value, "center")) {
                addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitMarginStart, CSSValueAuto);
                addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitMarginEnd, CSSValueAuto);
            } else
                addPropertyToPresentationAttributeStyle(style, CSSPropertyFloat, value);
        }
    } else if (name == rulesAttr) {
        // The presence of a valid rules attribute causes border collapsing to be enabled.
        if (m_rulesAttr != UnsetRules)
            addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderCollapse, CSSValueCollapse);
    } else if (name == frameAttr) {
        bool borderTop;
        bool borderRight;
        bool borderBottom;
        bool borderLeft;
        if (getBordersFromFrameAttributeValue(value, borderTop, borderRight, borderBottom, borderLeft)) {
            addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidth, CSSValueThin);
            addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderTopStyle, borderTop ? CSSValueSolid : CSSValueHidden);
            addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderBottomStyle, borderBottom ? CSSValueSolid : CSSValueHidden);
            addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderLeftStyle, borderLeft ? CSSValueSolid : CSSValueHidden);
            addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderRightStyle, borderRight ? CSSValueSolid : CSSValueHidden);
        }
    } else
        HTMLElement::collectStyleForPresentationAttribute(name, value, style);
}
コード例 #17
0
ファイル: mMainIndex.cpp プロジェクト: tsdv-candd/gameserver
int main(void)
{
	TCGI cgi;
	cgi.makeHeader(
			"text/html; charset=Windows-1251"
			"\nExpires: Mon, 26 Jul 1997 05:00:00 GMT"
			"\nX-Accel-Expires: 0"
//			"\nPragma: no-cache"
			"\nCache-Control: none");

	cgi.init();

	TStr Link(cgi.getParamValueByName("Link"));
	TStr Referrer(cgi.getParamValueByName("Referrer"));
	TStr Lang(cgi.getEnvironment("HTTP_ACCEPT_LANGUAGE"));

	if( Referrer.isEmpty() )
		Referrer = cgi.getEnvironment("HTTP_REFERER");

	TStr Language;
#ifdef CASINO_VABANK
	Lang = Lang.Copy(0,2);
	if( Lang != "en" && Lang != "ru" )
		Lang = "ru";
	TStr Cookie(cgi.getEnvironment("HTTP_COOKIE"));
	Cookie = Cookie.CopyAfter("lang=").CopyBefore(";");
	if( !Cookie.isEmpty() )
	{
		if( Cookie == "1" || Cookie == "RU" )
			Lang = "RU";
		else
			Lang = "EN";
	}
	if( TStr(cgi.getParamValueByName("lang")) == "ru" )
		Lang = "RU";
	if( TStr(cgi.getParamValueByName("lang")) == "en" )
		Lang = "EN";
	if( Lang.isEmpty() )
		Lang = "RU";
	if( Lang == "ru" )
		Language = "russian";
	else
		Language = "english";
#else
	Lang = "EN";
	Language = "english";
#endif

	TStr PID(cgi.getParamValueByName("cid")), PIDKEY;
	if( !PID.isEmpty() ) {
		PIDKEY = PID.CopyBefore(5);
	} else {
		if( cgi.paramCount() > 0 )
			if(
				cgi.getParamValue(0)[0] == '\0' &&
				TStr(cgi.getParamName(0)) != "referrer" &&
				TStr(cgi.getParamName(0)) != "link"
			)
				PID = cgi.getParamName(0);
		if( !PID.isEmpty() )
			PIDKEY = PID.CopyBefore(",");
	}

	TStr QUERY(cgi.getEnvironment("QUERY_STRING"));
	TStr IP(cgi.getEnvironment("REMOTE_ADDR"));
	m_classes::TMySqlConnect database;
	database.setHostName("localhost");
	database.setDatabase("casino_last");
	database.setLogin("root");
	database.setPasswd("");
	database.connect();
	m_classes::TMySqlQuery query(&database);
	query.execSql(
		"INSERT INTO log_url ("
			"fdate,"
			"ftime,"
			"freferrer,"
			"fip,"
			"fid,"
			"fidkey,"
			"fquery"
		") VALUES ("
			"now(),"
			"now(),"
			"'"+StrToSQL(Referrer)+"',"
			"'"+StrToSQL(IP)+"',"
			"'"+StrToSQL(PID)+"',"
			"'"+StrToSQL(PIDKEY)+"',"
			"'"+StrToSQL(QUERY)+"'"
		")");
	TStr RefID(query.last_id());
	try {
		TFile f;
		f.OpenLoad("index.ini");
		char Str[10000];
		int FileLen = fread(Str, 1, 10000, f.stream);
		Str[FileLen] = '\0';

		TStr _Str(Str,FileLen);

		_Str = _Str.Replace("$tb$",__escape(cgi.getParamValueByName("tb")));

		_Str = _Str.Replace("$LOG_PageReferrer$",__escape(cgi.getParamValueByName("Referrer")));
		_Str = _Str.Replace("$REFID$",RefID);
		_Str = _Str.Replace("$LANG$",ToLowerCase(Lang));
		_Str = _Str.Replace("$LANGUAGE$",Language);
		if( !Link.isEmpty() )
			Link = "&helpDefaultLink="+Link+"&";
		_Str = _Str.Replace("$LINK$",Link);
		printf("%s",_Str.c_str());
	} catch( ... ) {
		printf("error");
	}

	return 0;
}
コード例 #18
0
// In this method, we can clear |request| to tell content::WebURLLoaderImpl of
// Chromium not to follow the redirect. This works only when this method is
// called by RawResource::willSendRequest(). If called by
// RawResource::didAddClient(), clearing |request| won't be propagated to
// content::WebURLLoaderImpl. So, this loader must also get detached from the
// resource by calling clearResource().
bool DocumentThreadableLoader::redirectReceived(
    Resource* resource,
    const ResourceRequest& request,
    const ResourceResponse& redirectResponse) {
  DCHECK(m_client);
  DCHECK_EQ(resource, this->resource());
  DCHECK(m_async);

  m_checker.redirectReceived();

  if (!m_actualRequest.isNull()) {
    reportResponseReceived(resource->identifier(), redirectResponse);

    handlePreflightFailure(redirectResponse.url().getString(),
                           "Response for preflight is invalid (redirect)");

    return false;
  }

  if (m_redirectMode == WebURLRequest::FetchRedirectModeManual) {
    // We use |m_redirectMode| to check the original redirect mode. |request| is
    // a new request for redirect. So we don't set the redirect mode of it in
    // WebURLLoaderImpl::Context::OnReceivedRedirect().
    DCHECK(request.useStreamOnResponse());
    // There is no need to read the body of redirect response because there is
    // no way to read the body of opaque-redirect filtered response's internal
    // response.
    // TODO(horo): If we support any API which expose the internal body, we will
    // have to read the body. And also HTTPCache changes will be needed because
    // it doesn't store the body of redirect responses.
    responseReceived(resource, redirectResponse,
                     WTF::makeUnique<EmptyDataHandle>());

    if (m_client) {
      DCHECK(m_actualRequest.isNull());
      notifyFinished(resource);
    }

    return false;
  }

  if (m_redirectMode == WebURLRequest::FetchRedirectModeError) {
    ThreadableLoaderClient* client = m_client;
    clear();
    client->didFailRedirectCheck();

    return false;
  }

  // Allow same origin requests to continue after allowing clients to audit the
  // redirect.
  if (isAllowedRedirect(request.url())) {
    m_client->didReceiveRedirectTo(request.url());
    if (m_client->isDocumentThreadableLoaderClient()) {
      return static_cast<DocumentThreadableLoaderClient*>(m_client)
          ->willFollowRedirect(request, redirectResponse);
    }
    return true;
  }

  if (m_corsRedirectLimit <= 0) {
    ThreadableLoaderClient* client = m_client;
    clear();
    client->didFailRedirectCheck();
    return false;
  }

  --m_corsRedirectLimit;

  InspectorInstrumentation::didReceiveCORSRedirectResponse(
      document().frame(), resource->identifier(),
      document().frame()->loader().documentLoader(), redirectResponse,
      resource);

  bool allowRedirect = false;
  String accessControlErrorDescription;

  if (!CrossOriginAccessControl::isLegalRedirectLocation(
          request.url(), accessControlErrorDescription)) {
    accessControlErrorDescription =
        "Redirect from '" + redirectResponse.url().getString() +
        "' has been blocked by CORS policy: " + accessControlErrorDescription;
  } else if (!m_sameOriginRequest &&
             !passesAccessControlCheck(
                 redirectResponse, effectiveAllowCredentials(),
                 getSecurityOrigin(), accessControlErrorDescription,
                 m_requestContext)) {
    // The redirect response must pass the access control check if the original
    // request was not same-origin.
    accessControlErrorDescription =
        "Redirect from '" + redirectResponse.url().getString() + "' to '" +
        request.url().getString() + "' has been blocked by CORS policy: " +
        accessControlErrorDescription;
  } else {
    allowRedirect = true;
  }

  if (!allowRedirect) {
    ThreadableLoaderClient* client = m_client;
    clear();
    client->didFailAccessControlCheck(ResourceError(
        errorDomainBlinkInternal, 0, redirectResponse.url().getString(),
        accessControlErrorDescription));
    return false;
  }

  m_client->didReceiveRedirectTo(request.url());

  // FIXME: consider combining this with CORS redirect handling performed by
  // CrossOriginAccessControl::handleRedirect().
  clearResource();

  // If the original request wasn't same-origin, then if the request URL origin
  // is not same origin with the original URL origin, set the source origin to a
  // globally unique identifier. (If the original request was same-origin, the
  // origin of the new request should be the original URL origin.)
  if (!m_sameOriginRequest) {
    RefPtr<SecurityOrigin> originalOrigin =
        SecurityOrigin::create(redirectResponse.url());
    RefPtr<SecurityOrigin> requestOrigin =
        SecurityOrigin::create(request.url());
    if (!originalOrigin->isSameSchemeHostPort(requestOrigin.get()))
      m_securityOrigin = SecurityOrigin::createUnique();
  }
  // Force any subsequent requests to use these checks.
  m_sameOriginRequest = false;

  // Since the request is no longer same-origin, if the user didn't request
  // credentials in the first place, update our state so we neither request them
  // nor expect they must be allowed.
  if (m_resourceLoaderOptions.credentialsRequested ==
      ClientDidNotRequestCredentials)
    m_forceDoNotAllowStoredCredentials = true;

  // Save the referrer to use when following the redirect.
  m_overrideReferrer = true;
  m_referrerAfterRedirect =
      Referrer(request.httpReferrer(), request.getReferrerPolicy());

  ResourceRequest crossOriginRequest(request);

  // Remove any headers that may have been added by the network layer that cause
  // access control to fail.
  crossOriginRequest.clearHTTPReferrer();
  crossOriginRequest.clearHTTPOrigin();
  crossOriginRequest.clearHTTPUserAgent();
  // Add any request headers which we previously saved from the
  // original request.
  for (const auto& header : m_requestHeaders)
    crossOriginRequest.setHTTPHeaderField(header.key, header.value);
  makeCrossOriginAccessRequest(crossOriginRequest);

  return false;
}
コード例 #19
0
void ApplicationCacheHost::selectCacheWithManifest(const KURL& manifestURL)
{
    if (m_host && !m_host->selectCacheWithManifest(manifestURL)) {
        // It's a foreign entry, restart the current navigation from the top
        // of the navigation algorithm. The navigation will not result in the
        // same resource being loaded, because "foreign" entries are never picked
        // during navigation.
        // see WebCore::ApplicationCacheGroup::selectCache()
        LocalFrame* frame = m_documentLoader->frame();
        frame->navigationScheduler().scheduleLocationChange(frame->document(), frame->document()->url(), Referrer(frame->document()->referrer(), frame->document()->referrerPolicy()));
    }
}