Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Do not sync siteData fields that are data: URLs
Browse files Browse the repository at this point in the history
since they are likely to exceed the AWS upload limit.
fix #8023

Test Plan:
1. unit tests should pass
2. set up sync
3. Open about:about and bookmark it
4. Open chrome-extension://cjnmeadmgmiihncdidmfiabhenbggfjm/_generated_background_page.html and wait. you should not see any errors related to encodeDataToS3KeyArray.
  • Loading branch information
diracdeltas committed Apr 3, 2017
1 parent 0aece94 commit 1ef7252
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/lib/urlutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ const UrlUtil = {
* @returns {Boolean} Whether or not this is a data url.
*/
isDataUrl: function (url) {
return url.toLowerCase().startsWith('data:')
return typeof url === 'string' && url.toLowerCase().startsWith('data:')
},

/**
Expand Down
3 changes: 2 additions & 1 deletion js/state/syncUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Immutable = require('immutable')
const writeActions = require('../constants/sync/proto').actions
const siteTags = require('../constants/siteTags')
const siteUtil = require('./siteUtil')
const {isDataUrl} = require('../lib/urlutil')

const CATEGORY_MAP = {
bookmark: {
Expand Down Expand Up @@ -394,7 +395,7 @@ module.exports.createSiteData = (site, appState) => {
creationTime: 0
}
for (let field in site) {
if (field in siteData) {
if (field in siteData && !isDataUrl(site[field])) {
siteData[field] = site[field]
}
}
Expand Down
15 changes: 15 additions & 0 deletions test/unit/state/syncUtilTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ describe('syncUtil', () => {
}
assert.deepEqual(syncUtil.createSiteData(bookmark), expectedBookmark)
})

it('bookmark containing data url', () => {
const bookmark = Object.assign({}, site, {tags: ['bookmark'], favicon: 'data:foo'})
const newValue = Object.assign({}, expectedSite.value, {favicon: ''})
const expectedBookmark = {
name: 'bookmark',
objectId,
value: {
site: newValue,
isFolder: false,
parentFolderObjectId: undefined
}
}
assert.deepEqual(syncUtil.createSiteData(bookmark), expectedBookmark)
})
})

describe('ipcSafeObject()', () => {
Expand Down

0 comments on commit 1ef7252

Please sign in to comment.