Skip to content

Commit

Permalink
Merge branch 'master' into vault-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dhowe authored Dec 20, 2024
2 parents c543d50 + d94747a commit c2d898d
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 49 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
permissions:
contents: read

# I used the following project as template to get started:
# https://github.com/dessant/search-by-image/blob/master/.github/workflows/ci.yml

jobs:
build:
permissions:
Expand All @@ -28,24 +25,28 @@ jobs:
- name: Clone uAssets
run: |
tools/pull-assets.sh
# https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
- name: Get release information
id: release_info
run: |
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: Build MV2 packages
run: |
tools/make-chromium.sh ${{ env.VERSION }}
tools/make-firefox.sh ${{ env.VERSION }}
tools/make-thunderbird.sh ${{ env.VERSION }}
tools/make-npm.sh ${{ env.VERSION }}
- name: Assemble release notes
run: |
> release.body.txt
grep -m1 -B10000 -- "----------" CHANGELOG.md >> release.body.txt
sed -e 's/%version%/${{ steps.release_info.outputs.VERSION }}/g' RELEASE.HEAD.md >> release.body.txt
sed -e 's/%version%/${{ env.VERSION }}/g' RELEASE.HEAD.md >> release.body.txt
- name: Create GitHub release
id: create_release
uses: actions/create-release@v1
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ steps.release_info.outputs.VERSION }}
release_name: ${{ steps.release_info.outputs.VERSION }}
tag_name: ${{ env.VERSION }}
name: ${{ env.VERSION }}
draft: true
prerelease: true
body_path: release.body.txt
Expand Down
4 changes: 2 additions & 2 deletions assets/resources/safe-self.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ export function safeSelf() {
makeLogPrefix(...args) {
return this.sendToLogger && `[${args.join(' \u205D ')}]` || '';
},
uboLog(...args) {
adnlog(...args) {
if ( this.sendToLogger === undefined ) { return; }
if ( args === undefined || args[0] === '' ) { return; }
return this.sendToLogger('info', ...args);

},
uboErr(...args) {
adnErr(...args) {
if ( this.sendToLogger === undefined ) { return; }
if ( args === undefined || args[0] === '' ) { return; }
return this.sendToLogger('error', ...args);
Expand Down
20 changes: 10 additions & 10 deletions assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ function abortCurrentScriptCore(
}
});
} catch(ex) {
safe.uboErr(logPrefix, `Error: ${ex}`);
safe.adnErr(logPrefix, `Error: ${ex}`);
}
}

Expand Down Expand Up @@ -493,7 +493,7 @@ function setConstantFn(
});
safe.adnlog(logPrefix, 'Trap installed');
} catch(ex) {
safe.uboErr(logPrefix, ex);
safe.adnErr(logPrefix, ex);
}
};
const trapChain = function(owner, chain) {
Expand Down Expand Up @@ -1163,7 +1163,7 @@ function jsonPruneFetchResponseFn(
try {
objs[0] = safe.Request_clone.call(objs[0]);
} catch(ex) {
safe.uboErr(logPrefix, 'Error:', ex);
safe.adnErr(logPrefix, 'Error:', ex);
}
}
if ( args[1] instanceof Object ) {
Expand Down Expand Up @@ -1207,11 +1207,11 @@ function jsonPruneFetchResponseFn(
});
return responseAfter;
}).catch(reason => {
safe.uboErr(logPrefix, 'Error:', reason);
safe.adnErr(logPrefix, 'Error:', reason);
return responseBefore;
});
}).catch(reason => {
safe.uboErr(logPrefix, 'Error:', reason);
safe.adnErr(logPrefix, 'Error:', reason);
return fetchPromise;
});
};
Expand Down Expand Up @@ -1257,7 +1257,7 @@ function replaceFetchResponseFn(
objs[0] = safe.Request_clone.call(objs[0]);
}
catch(ex) {
safe.uboErr(logPrefix, ex);
safe.adnErr(logPrefix, ex);
}
}
if ( args[1] instanceof Object ) {
Expand Down Expand Up @@ -1294,11 +1294,11 @@ function replaceFetchResponseFn(
});
return responseAfter;
}).catch(reason => {
safe.uboErr(logPrefix, reason);
safe.adnErr(logPrefix, reason);
return responseBefore;
});
}).catch(reason => {
safe.uboErr(logPrefix, reason);
safe.adnErr(logPrefix, reason);
return fetchPromise;
});
}
Expand Down Expand Up @@ -2327,7 +2327,7 @@ function preventRefresh(
const logPrefix = safe.makeLogPrefix('prevent-refresh', delay);
const stop = content => {
window.stop();
safe.uboLog(logPrefix, `Prevented "${content}"`);
safe.adnlog(logPrefix, `Prevented "${content}"`);
};
const defuse = ( ) => {
const meta = document.querySelector('meta[http-equiv="refresh" i][content]');
Expand Down Expand Up @@ -3224,7 +3224,7 @@ function xmlPrune(
safe.adnlog(logPrefix, `${item.constructor.name}.${item.nodeName} removed`);
}
} catch(ex) {
safe.uboErr(logPrefix, `Error: ${ex}`);
safe.adnErr(logPrefix, `Error: ${ex}`);
}
return xmlDoc;
};
Expand Down
2 changes: 1 addition & 1 deletion assets/resources/set-attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function setAttrFn(
if ( attr.toLowerCase() in elem ) { continue; }
}
elem.setAttribute(attr, after);
safe.uboLog(logPrefix, `${attr}="${after}"`);
safe.adnlog(logPrefix, `${attr}="${after}"`);
}
return true;
};
Expand Down
2 changes: 1 addition & 1 deletion dist/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.61.0
1.61.2
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.23.3",
"version": "3.23.3.1",
"key": "ilkggpgmkemaniponkfgnkonpajankkm",
"author": "Daniel C. Howe",
"background": {
Expand Down
3 changes: 2 additions & 1 deletion src/css/vault.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ body {
font-stretch: 47.5%;
font-variation-settings: "opsz" 48, "slnt" 0, "GRAD" 0, "XTRA" 468, "YOPQ" 79, "YTAS" 750, "YTDE" -203, "YTFI" 738, "YTLC" 514, "YTUC" 712;
z-index: 50;
margin-bottom: 30px;
margin-bottom: 40px;
cursor: default;
user-select:none;
width:270px;
Expand Down Expand Up @@ -329,6 +329,7 @@ div.tooltip {
position: relative;
display: inline-block;
z-index: 100;
width: 700px;
font-size: 16px;
font-family: bebas_neue,roboto_flex,noto_sans,sans-serif;
font-stretch: 47.5%;
Expand Down
20 changes: 13 additions & 7 deletions src/js/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Home: https://github.com/gorhill/uBlock
*/

'use strict';
import * as sfp from './static-filtering-parser.js';

/******************************************************************************/

Expand All @@ -31,8 +31,7 @@ import cacheStorage from './cachestorage.js';
import { adnlog } from './console.js';
import { i18n$ } from './i18n.js';
import logger from './logger.js';
import * as sfp from './static-filtering-parser.js';
import { orphanizeString, } from './text-utils.js';
import { orphanizeString } from './text-utils.js';

/******************************************************************************/

Expand All @@ -52,6 +51,9 @@ let remoteServerFriendly = false;

/******************************************************************************/

const hasOwnProperty = (o, p) =>
Object.prototype.hasOwnProperty.call(o, p);

const stringIsNotEmpty = s => typeof s === 'string' && s !== '';

const parseExpires = s => {
Expand Down Expand Up @@ -109,8 +111,8 @@ const resourceTimeFromXhr = xhr => {

const resourceTimeFromParts = (parts, time) => {
const goodParts = parts.filter(part => typeof part === 'object');
return goodParts.reduce((acc, part) =>
((part.resourceTime || 0) > acc ? part.resourceTime : acc),
return goodParts.reduce(
(acc, part) => ((part.resourceTime || 0) > acc ? part.resourceTime : acc),
time
);
};
Expand Down Expand Up @@ -248,6 +250,7 @@ const fireNotification = function(topic, details) {
assets.fetch = function(url, options = {}) {
return new Promise((resolve, reject) => {
// Start of executor
/* eslint-disable indent */

const timeoutAfter = µb.hiddenSettings.assetFetchTimeout || 30;
const xhr = new XMLHttpRequest();
Expand Down Expand Up @@ -328,6 +331,7 @@ assets.fetch = function(url, options = {}) {
onErrorEvent.call(xhr);
}

/* eslint-enable indent */
// End of executor
});
};
Expand Down Expand Up @@ -739,7 +743,7 @@ async function assetCacheRead(assetKey, updateReadTime = false) {
}

if ( bin instanceof Object === false ) { return reportBack(''); }
if ( bin.hasOwnProperty(internalKey) === false ) { return reportBack(''); }
if ( hasOwnProperty(bin, internalKey) === false ) { return reportBack(''); }

const entry = assetCacheRegistry[assetKey];
if ( entry === undefined ) { return reportBack(''); }
Expand Down Expand Up @@ -1288,7 +1292,9 @@ async function diffUpdater() {
if ( data.status === 'needtext' ) {
adnlog('Diff updater: need text for', data.assetKey);
assetCacheRead(data.assetKey).then(result => {
data.text = result.content;
// https://bugzilla.mozilla.org/show_bug.cgi?id=1929326#c9
// Must never be set to undefined!
data.text = result.content || '';
data.status = undefined;
checkAndCorrectDiffPath(data);
bc.postMessage(data);
Expand Down
36 changes: 20 additions & 16 deletions src/js/s14e-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1097,32 +1097,36 @@ export const serialize = (data, options = {}) => {
return ratio <= 0.85 ? t : s;
};

export const deserialize = s => {
if ( s.startsWith(MAGICLZ4PREFIX) ) {
refCounter = 1;
readStr = s;
readEnd = s.length;
readPtr = MAGICLZ4PREFIX.length;
const lz4 = _deserialize();
readRefs.clear();
readStr = '';
const lz4Util = new LZ4BlockJS();
const uint8ArrayAfter = lz4Util.decode(lz4.data, 0, lz4.size);
s = textCodec.decode(new Uint8Array(uint8ArrayAfter));
}
if ( s.startsWith(MAGICPREFIX) === false ) { return; }
const deserializeById = (blockid, s) => {
refCounter = 1;
readStr = s;
readEnd = s.length;
readPtr = MAGICPREFIX.length;
readPtr = blockid.length;
const data = _deserialize();
readRefs.clear();
readStr = '';
uint8Input = null;
if ( readPtr === FAILMARK ) { return; }
return data;
};

export const deserialize = s => {
if ( s.startsWith(MAGICLZ4PREFIX) ) {
const lz4 = deserializeById(MAGICLZ4PREFIX, s);
if ( lz4 ) {
const lz4Util = new LZ4BlockJS();
const uint8ArrayAfter = lz4Util.decode(lz4.data, 0, lz4.size);
if ( uint8ArrayAfter ) {
s = textCodec.decode(new Uint8Array(uint8ArrayAfter));
}
}
}
const data = s.startsWith(MAGICPREFIX)
? deserializeById(MAGICPREFIX, s)
: undefined;
uint8Input = null;
return data;
};

export const isSerialized = s =>
typeof s === 'string' &&
(s.startsWith(MAGICLZ4PREFIX) || s.startsWith(MAGICPREFIX));
Expand Down
1 change: 1 addition & 0 deletions src/js/traffic.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ const onBeforeRootFrameRequest = function (fctxt) {
if ( trusted === false && pageStore !== null ) {
if ( result !== 1 ) {
pageStore.redirectNonBlockedRequest(fctxt);
// adn Q: fctxt is often undefined here, but we've already referenced its type and tabId ??
logRedirect(fctxt, 'beforeRequest.non-blocked'); // ADN: redirect unblocked
} else {
pageStore.skipMainDocument(fctxt, true);
Expand Down
2 changes: 2 additions & 0 deletions tools/copy-common-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
DES=$1
UBLOCK=$( cat dist/version ) # ADN:ublock-version

bash ./tools/pull-assets.sh # ADN

bash ./tools/make-assets.sh $DES
bash ./tools/make-locales.sh $DES

Expand Down

0 comments on commit c2d898d

Please sign in to comment.