noscript refuses to trust localhost

Ask for help about NoScript, no registration needed to post
frpatte
Posts: 2
Joined: Mon Dec 11, 2017 9:09 am

noscript refuses to trust localhost

Post by frpatte » Thu Mar 15, 2018 9:56 am

Bonjour,

I am facing a problem, I can't access my dlna server on my own machine (localhost). I have the emby server installed on my computer and when I want to connect (localhost:8096), noscript blocks the access. If I try to mark the page as trusted, a small locker appears saying "match https content only". And I can't do anything to unlock this page.....

Thank you for helping.

F.P.
Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0

skriptimaahinen
Senior Member
Posts: 213
Joined: Wed Jan 10, 2018 7:37 am

Re: noscript refuses to trust localhost

Post by skriptimaahinen » Thu Mar 15, 2018 11:26 am

Enabling "List full addresses in the permissions popup (https://www.noscript.net)" in the Appearance options makes the localhost line visible again.

The purpose of the empty line is unclear to me though.
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0

frpatte
Posts: 2
Joined: Mon Dec 11, 2017 9:09 am

Re: noscript refuses to trust localhost

Post by frpatte » Thu Mar 15, 2018 2:07 pm

Ok! Thank you, this done the job.

F.P.
Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0

skriptimaahinen
Senior Member
Posts: 213
Joined: Wed Jan 10, 2018 7:37 am

Re: noscript refuses to trust localhost

Post by skriptimaahinen » Fri Mar 16, 2018 12:15 pm

Turns out the empty line is supposed to be the domain line for the localhost, but since tld.js doesn't recognize localhost as valid top level domain, the line is left empty.

tld.js behaviour is bit odd though, as the next tests show:

input -> returns
"localhost" -> ""
"localhost:8000" -> ""
"http://localhost" -> ""
"http://localhost:8000" -> "http://localhost:8000"
"foo.localhost" -> "foo.localhost"
"foo.localhost:8000" -> "foo.localhost:8000"

Luckily there appears to be an easy fix for our problem. Simply add one line as shown below.

Code: Select all

tld.js

getDomain(domain) {
    if (domain == "localhost") return domain; // added line
    if (this.isIp(domain)) return domain;
    ...
This should be OK as long as getDomain is fed only hostnames, so the port number or protocol are not going to be issues. Alternatively you could get fancy with regexps, or update the tld.js. The newer version seems to have feature to import custom hostnames like localhost.
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0

barbaz
Senior Member
Posts: 9666
Joined: Sat Aug 03, 2013 5:45 pm

Re: noscript refuses to trust localhost

Post by barbaz » Fri Mar 16, 2018 2:15 pm

This affects all no-dot domains, not just localhost.

NoScript Classic solved this by always showing only the full address for no-dot domains, regardless of the setting to show full addresses.
*Always* check the changelogs BEFORE updating that important software!
-

User avatar
Giorgio Maone
Site Admin
Posts: 8939
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: noscript refuses to trust localhost

Post by Giorgio Maone » Fri Mar 16, 2018 11:45 pm

Included the localhost exception in latest development build, likely will switch to classic's approach in 10.1.7.4.
v 10.1.7.3rc1
=============================================================
x Fixed infinite script count report loops on some sites
(thanks AuntyJack, @ALoss2 and others for reporting)
x Fixed localhost not being recognized as a domain (thanks
skriptimaahinen for patch)

x Fixed regression causing NOSCRIPT element and META refreshes
not to be emulated anymore on script-disabled pages (thanks
barbaz and fatboy for reporting)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0

Post Reply