mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
[mv3] Better validate hostnames in "Filtering mode details" editor
Related issue: https://github.com/uBlockOrigin/uBOL-home/issues/564
This commit is contained in:
parent
cdfa514c2a
commit
621ad89c64
3 changed files with 16 additions and 4 deletions
|
|
@ -60,7 +60,7 @@ section[data-pane="develop"] > div > * {
|
|||
:root.dark #cm-container .cm-editor .cm-line .ubol-literal {
|
||||
color: #1dae74;
|
||||
}
|
||||
#cm-container .cm-editor .cm-line.badline:not(.cm-activeLine) {
|
||||
#cm-container .cm-editor .cm-line.badline {
|
||||
background-color: color-mix(in srgb, var(--info3-ink) 15%, transparent 85%);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -515,7 +515,7 @@ export function rulesFromText(text) {
|
|||
if ( indices.length === 0 ) { continue; }
|
||||
const result = ruleFromLines(lines, indices);
|
||||
if ( result.bad ) {
|
||||
bad.push(...result.bad.slice(4));
|
||||
bad.push(...result.bad.slice(0, 4));
|
||||
} else if ( result.rule ) {
|
||||
rules.push(result.rule);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,8 +89,20 @@ const perScopeParsers = {
|
|||
};
|
||||
|
||||
const addHostnameToMode = (modes, mode, node) => {
|
||||
if ( node.list !== true ) { return false; }
|
||||
modes[mode].push(punycode.toASCII(node.val));
|
||||
if ( node.list !== true ) { return node.val === '-'; }
|
||||
if ( node.key !== undefined ) { return false; }
|
||||
if ( node.val === undefined ) { return false; }
|
||||
const hn = punycode.toASCII(node.val.toLowerCase());
|
||||
if ( hn.length > 253 ) { return false; }
|
||||
if ( hn.split('.').some(isInvalidLabel) ) { return false; }
|
||||
modes[mode].push(hn);
|
||||
};
|
||||
|
||||
const isInvalidLabel = label => {
|
||||
if ( label.length === 0 ) { return true; }
|
||||
if ( label.length > 63 ) { return true; }
|
||||
if ( /^[^\da-z]|[^\da-z]$|[^\da-z-]/.test(label) ) { return true; }
|
||||
return false;
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
Loading…
Reference in a new issue