From 811e742b4bdb393cc9dc092d9d61af2bb879a047 Mon Sep 17 00:00:00 2001 From: yan Date: Mon, 27 Jun 2016 15:38:08 -0700 Subject: [PATCH] Set true user agent on adobe domains Auditors: @bbondy --- app/filtering.js | 6 ++++-- js/components/frame.js | 5 ++++- js/constants/appConfig.js | 5 ++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/filtering.js b/app/filtering.js index 9d88402ad33..23ccd7b6e61 100644 --- a/app/filtering.js +++ b/app/filtering.js @@ -158,6 +158,7 @@ function registerForBeforeSendHeaders (session) { } let requestHeaders = details.requestHeaders + let parsedUrl = urlParse(details.url || '') if (!spoofedUserAgent) { // To minimize fingerprintability, remove Brave from the UA string. @@ -167,7 +168,9 @@ function registerForBeforeSendHeaders (session) { appActions.changeSetting(settings.USERAGENT, spoofedUserAgent) } - requestHeaders['User-Agent'] = spoofedUserAgent + if (!appConfig.uaExceptionHosts.includes(parsedUrl.hostname)) { + requestHeaders['User-Agent'] = spoofedUserAgent + } for (let i = 0; i < beforeSendHeadersFilteringFns.length; i++) { let results = beforeSendHeadersFilteringFns[i](details) @@ -183,7 +186,6 @@ function registerForBeforeSendHeaders (session) { } } - let parsedUrl = urlParse(details.url || '') if (module.exports.isResourceEnabled(appConfig.resourceNames.COOKIEBLOCK, details.firstPartyUrl)) { if (module.exports.isThirdPartyHost(urlParse(details.firstPartyUrl || '').hostname, parsedUrl.hostname)) { diff --git a/js/components/frame.js b/js/components/frame.js index 12cc0084c69..e8de03a26eb 100644 --- a/js/components/frame.js +++ b/js/components/frame.js @@ -28,6 +28,7 @@ const consoleStrings = require('../constants/console') const { aboutUrls, isSourceAboutUrl, isTargetAboutUrl, getTargetAboutUrl, getBaseUrl } = require('../lib/appUrlUtil') const { isFrameError } = require('../lib/errorUtil') const locale = require('../l10n') +const appConfig = require('../constants/appConfig') class Frame extends ImmutableComponent { constructor () { @@ -142,9 +143,11 @@ class Frame extends ImmutableComponent { } this.webview.setAttribute('allowDisplayingInsecureContent', true) this.webview.setAttribute('data-frame-key', this.props.frame.get('key')) - this.webview.setAttribute('useragent', getSetting(settings.USERAGENT) || '') const parsedUrl = urlParse(location) + if (!appConfig.uaExceptionHosts.includes(parsedUrl.hostname)) { + this.webview.setAttribute('useragent', getSetting(settings.USERAGENT) || '') + } const hack = siteHacks[parsedUrl.hostname] if (hack && hack.userAgent) { this.webview.setAttribute('useragent', hack.userAgent) diff --git a/js/constants/appConfig.js b/js/constants/appConfig.js index 159ea11b4dd..04d2f664e30 100644 --- a/js/constants/appConfig.js +++ b/js/constants/appConfig.js @@ -106,5 +106,8 @@ module.exports = { 'general.disable-title-mode': process.platform === 'win32', 'advanced.hardware-acceleration-enabled': true, 'advanced.default-zoom-level': null - } + }, + uaExceptionHosts: [ + 'get.adobe.com', 'adobe.com', 'www.adobe.com', 'helpx.adobe.com' + ] // hosts to send true UA to }