WGET BUG with url name with UPPERCASE letter in file name

WGET BUG with url name with UPPERCASE letter in file name

Postby Acquarious81 » Sun Dec 13, 2015 1:52 am

Hi ,

there is a bug on wget tabs.. if the name of the file in the url have a UPPERCASE Letter.. the accept button is disable and don't accept to proceed...

Uppercase letters is not a problem with html url... but in FTP url can be..

for resolve this bug simply add A-Z to the regex in the original files.. so..

/usr/htdocs/.torrent/wget_download_m.htm

from
Code: Select all
//check url
function ValidURL(str) {
    valid=/^((https?|ftp):\/\/)?((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3}))(\:\d+)?(\/[-a-z\d%_\.~\+]*)*(\?[;&a-z\d%_\.~\+=-]*)?(\#[-a-z\d_]*)?$/i.test(str);
   return valid;
}

to
Code: Select all
//check url
function ValidURL(str) {
    valid=/^((https?|ftp):\/\/)?((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3}))(\:\d+)?(\/[-a-zA-Z\d%_\.~\+]*)*(\?[;&a-z\d%_\.~\+=-]*)?(\#[-a-z\d_]*)?$/i.test(str);
   return valid;
}


and /usr/htdocs/global/wget_download_m.xml

from
Code: Select all
if(preg_match('/^(?:(https?|ftp):\/\/)?((?:(?:[a-z\d](?:[a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((?:\d{1,3}\.){3}\d{1,3}))(?:\:\d+)?(?:\/[-a-z\d%_\.~\+]*)*(?:\?[;&a-z\d%_\.~\+=-]*)?(?:\#[-a-z\d_]*)?$/i',$_SESSION['wget']['url'],$match)){//we have a domain name or ip adress!

to
Code: Select all
if(preg_match('/^(?:(https?|ftp):\/\/)?((?:(?:[a-z\d](?:[a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((?:\d{1,3}\.){3}\d{1,3}))(?:\:\d+)?(?:\/[-a-zA-Z\d%_\.~\+]*)*(?:\?[;&a-z\d%_\.~\+=-]*)?(?:\#[-a-z\d_]*)?$/i',$_SESSION['wget']['url'],$match)){//we have a domain name or ip adress!


and NOW ... all goes right...
Acquarious81
Donator VIP
Donator VIP
 
Posts: 24
Joined: Sat Nov 28, 2015 8:28 pm

Re: WGET BUG with url name with UPPERCASE letter in file nam

Postby Jocko » Mon Dec 14, 2015 10:26 am

Hi Acquarious81

Thank you for this feedback.

But not all goes right ;)

Indeed as you can read in the original regexp (in xml and htm file) the modifier 'i' is used so the regexp should be case-insensitive.

With the url you have posted, your url matches the pattern without your change at least with php code. So add A-Z should be useless in xml file.
You can check this with the regexp tester online : http://www.lumadis.be/regex/test_regex.php?lang=en

But need to find why in js code the regexp does not work (your url does not match even with the modifier 'i' :scratch )

Anyhow the original code does not work with special characters in path or filename if they contain : (),;:~... which is possible as with linux you can use any character (and also \n !!!)

For this last point, the files that I sent you fix this issue.

So just need to understand why the modifier 'i' does not work.
Jocko
Site Admin - expert
 
Posts: 11529
Joined: Tue Apr 12, 2011 4:48 pm
Location: Orleans, France

Re: WGET BUG with url name with UPPERCASE letter in file nam

Postby Jocko » Mon Dec 14, 2015 7:10 pm

After some others tests I confirm your change does not fix your issue if ftp url contains special characters.

So you need to use my version sent the last WE. You get an error because my regexp used in the xml file requires to set the port in the url (=> add :21). if you add the port, you can download any ftp url with a-z or A-Z characters.

But I found also there is an additional check (in validfunction.js) which rejects the url if it contains special characters. So I fixed this check step.

Moreover, as now the url may contain special characters, we must escape the url string to succeed to retrieve the files but also for safety. Indeed, for example if the url contains the substring " ; rm -r / ; " then the script will try to delete all files on the nas without escaping of the shell command :whistle.

So now the menu escapes the url in the command line.

Last point I also improved how the menu handles the paste event on the url input field. You find the new files in your pm.
Jocko
Site Admin - expert
 
Posts: 11529
Joined: Tue Apr 12, 2011 4:48 pm
Location: Orleans, France


Return to Lacie Network Space vs2 and max version

Who is online

Users browsing this forum: No registered users and 3 guests