Do not use tab character as field separator

Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/2730#issuecomment-1881821674

Character `\x1F` is now used instead.
This commit is contained in:
Raymond Hill 2024-01-09 14:31:00 -05:00
parent 17be8dafc5
commit a9eb9630cf
No known key found for this signature in database
GPG key ID: 25E1490B761470C2
2 changed files with 24 additions and 16 deletions

View file

@ -377,7 +377,7 @@ const createLogSeparator = function(details, text) {
// cell 1
text
);
separator.textContent = textContent.join('\t');
separator.textContent = textContent.join('\x1F');
if ( details.voided ) {
separator.voided = true;
@ -474,7 +474,7 @@ const parseLogEntry = function(details) {
// Cell 1
if ( details.realm === 'message' ) {
textContent.push(details.text);
entry.textContent = textContent.join('\t');
entry.textContent = textContent.join('\x1F');
return entry;
}
@ -545,7 +545,7 @@ const parseLogEntry = function(details) {
textContent.push(`aliasURL=${details.aliasURL}`);
}
entry.textContent = textContent.join('\t');
entry.textContent = textContent.join('\x1F');
return entry;
};
@ -744,7 +744,7 @@ const viewPort = (( ) => {
vwEntry.logEntry = details;
const cells = details.textContent.split('\t');
const cells = details.textContent.split('\x1F');
const div = dom.clone(vwLogEntryTemplate);
const divcl = div.classList;
let span;
@ -863,7 +863,7 @@ const viewPort = (( ) => {
// Alias URL (CNAME, etc.)
if ( cells.length > 8 ) {
const pos = details.textContent.lastIndexOf('\taliasURL=');
const pos = details.textContent.lastIndexOf('\x1FaliasURL=');
if ( pos !== -1 ) {
dom.attr(div, 'data-aliasid', details.id);
}
@ -1621,7 +1621,7 @@ dom.on(document, 'keydown', ev => {
if ( id === '' ) { return ''; }
for ( const entry of loggerEntries ) {
if ( entry.id !== id || entry.aliased ) { continue; }
const fields = entry.textContent.split('\t');
const fields = entry.textContent.split('\x1F');
return fields[COLUMN_URL] || '';
}
return '';
@ -2682,7 +2682,7 @@ const loggerStats = (( ) => {
const text = entry.textContent;
const fields = [];
let i = 0;
let beg = text.indexOf('\t');
let beg = text.indexOf('\x1F');
if ( beg === 0 ) { continue; }
let timeField = text.slice(0, beg);
if ( options.time === 'anonymous' ) {
@ -2691,7 +2691,7 @@ const loggerStats = (( ) => {
fields.push(timeField);
beg += 1;
while ( beg < text.length ) {
let end = text.indexOf('\t', beg);
let end = text.indexOf('\x1F', beg);
if ( end === -1 ) { end = text.length; }
fields.push(text.slice(beg, end));
beg = end + 1;
@ -3020,6 +3020,14 @@ dom.on('#pageSelector', 'change', pageSelectorChanged);
dom.on('#netInspector .vCompactToggler', 'click', toggleVCompactView);
dom.on('#pause', 'click', pauseNetInspector);
dom.on('#netInspector', 'copy', ev => {
const selection = document.getSelection();
ev.clipboardData.setData('text/plain',
selection.toString().replace(/\x1F|\u200B/g, '\t')
);
ev.preventDefault();
});
// https://github.com/gorhill/uBlock/issues/507
// Ensure tab selector is in sync with URL hash
pageSelectorFromURLHash();

View file

@ -58,22 +58,22 @@
<input type="search" placeholder="logFilterPrompt" spellcheck="false">
<span id="filterExprButton" class="button fa-icon expanded" data-i18n-title="loggerRowFiltererBuiltinTip">angle-up</span>
<div id="filterExprPicker">
<div><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span><span data-filtex="\t--\t|\t<<\t|\t##" data-i18n="loggerRowFiltererBuiltinBlocked"></span><span data-filtex="\t\+\+\t|\t\*\*\t|\t#@#" data-i18n="loggerRowFiltererBuiltinAllowed"></span><span data-filtex="[$,](?:csp|permissions|removeparam|redirect-rule|replace|urltransform)=|\t\<\<\t" data-i18n="loggerRowFiltererBuiltinModified"></span></div>
<div><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span><span data-filtex="\x1F--\x1F|\x1F<<\x1F|\x1F##" data-i18n="loggerRowFiltererBuiltinBlocked"></span><span data-filtex="\x1F\+\+\x1F|\x1F\*\*\x1F|\x1F#@#" data-i18n="loggerRowFiltererBuiltinAllowed"></span><span data-filtex="[$,](?:csp|permissions|removeparam|redirect-rule|replace|urltransform)=|\x1F\<\<\x1F" data-i18n="loggerRowFiltererBuiltinModified"></span></div>
<div><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span>
<span style="flex-direction: column;">
<div><span data-filtex="\t(?:css|(?:inline-)?font)\t">css/font</span><span data-filtex="\timage\t">image</span><span data-filtex="\tmedia\t">media</span><span data-filtex="\t(?:inline-)?script(?:ing)?\t">script</span></div>
<div><span data-filtex="\t(?:websocket|xhr)\t">xhr</span><span data-filtex="\t(?:frame|object)\t">frame</span><span data-filtex="\t(?:dom|g(?:eneric)?hide|s(?:pecific)?hide)\t">dom</span><span data-filtex="\t(?:scriptlet)\t">scriptlet</span><span data-filtex="\t(?:beacon|csp_report|doc|ping|popup|popunder|other)\t">other</span></div>
<div><span data-filtex="\x1F(?:css|(?:inline-)?font)\x1F">css/font</span><span data-filtex="\x1Fimage\x1F">image</span><span data-filtex="\x1Fmedia\x1F">media</span><span data-filtex="\x1F(?:inline-)?script(?:ing)?\x1F">script</span></div>
<div><span data-filtex="\x1F(?:websocket|xhr)\x1F">xhr</span><span data-filtex="\x1F(?:frame|object)\x1F">frame</span><span data-filtex="\x1F(?:dom|g(?:eneric)?hide|s(?:pecific)?hide)\x1F">dom</span><span data-filtex="\x1F(?:scriptlet)\x1F">scriptlet</span><span data-filtex="\x1F(?:beacon|csp_report|doc|ping|popup|popunder|other)\x1F">other</span></div>
</span>
</div>
<div><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span><span data-filtex="\t(?:0,)?1\t" data-i18n="loggerRowFiltererBuiltin1p"></span><span data-filtex="\t(?:3(?:,\d)?|0,3)\t" data-i18n="loggerRowFiltererBuiltin3p"></span><span data-filtex="\t0,\d\t">tabless</span></div>
<div><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span><span data-filtex="\tget\t">get</span><span data-filtex="\thead\t">head</span><span data-filtex="\tpost\t">post</span></div>
<div><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span><span data-filtex="\x1F(?:0,)?1\x1F" data-i18n="loggerRowFiltererBuiltin1p"></span><span data-filtex="\x1F(?:3(?:,\d)?|0,3)\x1F" data-i18n="loggerRowFiltererBuiltin3p"></span><span data-filtex="\x1F0,\d\x1F">tabless</span></div>
<div><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span><span data-filtex="\x1Fget\x1F">get</span><span data-filtex="\x1Fhead\x1F">head</span><span data-filtex="\x1Fpost\x1F">post</span></div>
<div><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot" class="on"></span>
<span style="flex-direction: column;">
<div><span data-filtex="\bcsp=[^\t]+\t(?:--|\+\+)\t">csp</span><span data-filtex="\bpermissions=[^\t]+\t(?:--|\+\+)\t" class="on">permissions</span><span data-filtex="\bredirect-rule=[^\t]+\t(?:--|\+\+)\t">redirect</span></div>
<div><span data-filtex="\bremoveparam=[^\t]+\t(?:--|\+\+)\t">removeparam</span><span data-filtex="\burltransform=[^\t]+\t(?:--|\+\+)\t">urltransform</span></div>
<div><span data-filtex="\bcsp=[^\x1F]+\x1F(?:--|\+\+)\x1F">csp</span><span data-filtex="\bpermissions=[^\x1F]+\x1F(?:--|\+\+)\x1F" class="on">permissions</span><span data-filtex="\bredirect-rule=[^\x1F]+\x1F(?:--|\+\+)\x1F">redirect</span></div>
<div><span data-filtex="\bremoveparam=[^\x1F]+\x1F(?:--|\+\+)\x1F">removeparam</span><span data-filtex="\burltransform=[^\x1F]+\x1F(?:--|\+\+)\x1F">urltransform</span></div>
</span>
</div>
<div id="filterExprCnameOf" style="display:none"><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span><span data-filtex="\taliasURL=.">CNAME</span></div>
<div id="filterExprCnameOf" style="display:none"><span data-filtex="!" data-i18n="loggerRowFiltererBuiltinNot"></span><span data-filtex="\x1FaliasURL=.">CNAME</span></div>
</div>
</span>
</span>