Port_Authority icon indicating copy to clipboard operation
Port_Authority copied to clipboard

[Feature Request] Improve `cancel()`'s blocking logic (aka axe the regexes)

Open mwsundberg opened this issue 10 months ago • 3 comments

Is your feature request related to a problem? Please describe. The massive regex is hard to work with or update. It's unclear at a glance if IPv6 is covered, or any other weird LAN access method (uAssets' LAN list is a good reference compendium). Also with all of the host matching crammed in one big regex it's slower to execute (ie checking a plain localhost inherently has to run every single other check, no early returning for the easy match cases). There are also false-positives in the form of LAN addresses as subdomains of a non-LAN domain (eg localhost.remote.domain.com and 127.0.0.1.example.com are considered LAN). A security risk associated with visiting those false-positive domains was identified in #54 and patched in #55, but the underlying class of false positives remains unfixed.

Describe the solution you'd like Refactoring the regex and other blocking logic into a separate matching function with early returns for simple cases (ideally using js native string === string checking for speed) and pre-compiled regexes for the more complex blocking behavior.

Describe alternatives you've considered Keeping it as is—if it ain't broke don't fix it. The current blocking gets the job done, and it's not like they add new LAN ip's on a daily basis.

Additional context I certainly don't want to step on toes making too many changes. That said, I'd be willing to make a PR to address this, given the go-ahead.

mwsundberg avatar Mar 02 '25 09:03 mwsundberg