Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all permission requests from the Chrome manifest. #200

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ function transformManifest( content, target ) {
}

if ( target === 'chrome' ) {
delete content.permissions;
delete content.browser_specific_settings;
} else {
// Firefox doesn't have support for the CodeEditor for now.
Expand Down
10 changes: 7 additions & 3 deletions src/app/modules/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,20 @@ export function injectFunctionExecution( fn ) {
export function openXmlHttpRequest( url, method = 'POST' ) {
const location = window.__getLocation();

const isLocal = url.startsWith( '/' );

// Firefox needs the whole url, so we fix it here, if necessary.
if ( url.startsWith( '/' ) ) {
if ( isLocal ) {
url = `${ location.protocol }//${ location.host }${ url }`;
}

const xhr = new XMLHttpRequest();
xhr.open( method, url, true );

// Some of the requests don't work without this one.
xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest' );
if ( isLocal ) {
// GitHub requires this on some of the local XHR requests.
xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest' );
}

return xhr;
}
Expand Down
1 change: 1 addition & 0 deletions src/extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"permissions": [
// Amazon S3 is used by GitHub to upload files. We need to have permissions on it,
// so we avoid cross-origin issues when mimicking the upload within the GitHubUploadAdapter class.
// Firefox only.
"https://*.s3.amazonaws.com/"
],
"content_scripts": [
Expand Down