Skip to content
Closed
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"type": "module",
"scripts": {
"build": "deno build.ts --tagName 1.67.0 > ubo.js",
"build": "deno build.ts --tagName 1.67.1b1 > ubo.js",
"test": "node --test"
},
"author": {
Expand Down
102 changes: 56 additions & 46 deletions ubo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2231,9 +2231,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -2991,9 +2991,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -3751,9 +3751,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -4511,9 +4511,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -5271,9 +5271,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -6057,9 +6057,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -6798,9 +6798,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -7553,9 +7553,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -8308,9 +8308,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -9046,9 +9046,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -9868,9 +9868,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -10702,9 +10702,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -11536,9 +11536,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -12366,9 +12366,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -13134,9 +13134,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -13903,9 +13903,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -14756,9 +14756,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -15617,9 +15617,9 @@ class JSONPath {
break;
}
if ( c === 0x5C /* \ */ && (end+1) < len ) {
parts.push(query.slice(beg, end));
const d = query.charCodeAt(end+1);
if ( d === targetCharCode || d === 0x5C ) {
if ( d === targetCharCode ) {
parts.push(query.slice(beg, end));
end += 1;
beg = end;
}
Expand Down Expand Up @@ -19500,9 +19500,14 @@ function preventFetchFn(
const responseProps = {
statusText: { value: 'OK' },
};
const responseHeaders = {};
if ( /^\{.*\}$/.test(responseType) ) {
try {
Object.entries(JSON.parse(responseType)).forEach(([ p, v ]) => {
if ( p === 'headers' && trusted ) {
Object.assign(responseHeaders, v);
return;
}
if ( validResponseProps[p] === undefined ) { return; }
if ( validResponseProps[p].includes(v) === false ) { return; }
responseProps[p] = { value: v };
Expand Down Expand Up @@ -19555,11 +19560,11 @@ function preventFetchFn(
}
return Promise.resolve(generateContentFn(trusted, responseBody)).then(text => {
safe.uboLog(logPrefix, `Prevented with response "${text}"`);
const response = new Response(text, {
headers: {
'Content-Length': text.length,
}
});
const headers = Object.assign({}, responseHeaders);
if ( headers['content-length'] === undefined ) {
headers['content-length'] = text.length;
}
const response = new Response(text, { headers });
const props = Object.assign(
{ url: { value: details.url } },
responseProps
Expand Down Expand Up @@ -19955,9 +19960,14 @@ function preventFetchFn(
const responseProps = {
statusText: { value: 'OK' },
};
const responseHeaders = {};
if ( /^\{.*\}$/.test(responseType) ) {
try {
Object.entries(JSON.parse(responseType)).forEach(([ p, v ]) => {
if ( p === 'headers' && trusted ) {
Object.assign(responseHeaders, v);
return;
}
if ( validResponseProps[p] === undefined ) { return; }
if ( validResponseProps[p].includes(v) === false ) { return; }
responseProps[p] = { value: v };
Expand Down Expand Up @@ -20010,11 +20020,11 @@ function preventFetchFn(
}
return Promise.resolve(generateContentFn(trusted, responseBody)).then(text => {
safe.uboLog(logPrefix, `Prevented with response "${text}"`);
const response = new Response(text, {
headers: {
'Content-Length': text.length,
}
});
const headers = Object.assign({}, responseHeaders);
if ( headers['content-length'] === undefined ) {
headers['content-length'] = text.length;
}
const response = new Response(text, { headers });
const props = Object.assign(
{ url: { value: details.url } },
responseProps
Expand Down