ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Downloading long urls
@ 2011-01-16  5:12 Aditya Mahajan
  2011-01-21 17:15 ` Aditya Mahajan
  0 siblings, 1 reply; 8+ messages in thread
From: Aditya Mahajan @ 2011-01-16  5:12 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

While downloading urls, context santizes the filename but does not check 
the length of the url. So, one can end up with a situation where the 
filename is too long for the operating system to handle. For example, the 
following fails on 32bit linux.

\enabletrackers[resolvers.schemes]
\startluacode
   local report_webfilter = logs.new("thirddata.webfilter")

   local url = 
"http://www.bing.com/search?q=AreallyreallylongstringjusttoseehowthingsworkordontworkAreallyreallylongstringjusttoseehowthingsworkordontworkAreallyreallylongstringjusttoseehowthingsworkordontworkAreallyreallylongstringjusttoseehowthingsworkordontworAreallyreallylongstringjusttoseehowthingsworkordontworkkAreallyreallylongstringjusttoseehowthingsworkordontwork"

   local specification = resolvers.splitmethod(url)

   local file       = resolvers.finders['http'](specification) or ""

   if file and file ~= "" then
     report_webfilter("saving file %s", file)
   else
     report_webfilter("download failed")
   end
\stopluacode

\normalend

Is there a robust way to avoid this problem? One possibility is that in 
data-sch.lua instead of

     local cleanname = gsub(original,"[^%a%d%.]+","-")

use

     local cleanname = md5sum(original)

What do you think?

Aditya

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-01-23 21:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-16  5:12 Downloading long urls Aditya Mahajan
2011-01-21 17:15 ` Aditya Mahajan
2011-01-21 22:53   ` Hans Hagen
2011-01-22  0:20     ` Aditya Mahajan
2011-01-23 20:22       ` Hans Hagen
2011-01-23 20:34         ` Aditya Mahajan
2011-01-23 20:54           ` Hans Hagen
2011-01-23 21:10             ` Aditya Mahajan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).