From: itinerants <iti...@ho...> - 2007-11-15 14:21:42
|
On 15/11/07 2:00 pm, "poy" <po...@12...> wrote: In fact, I've looked into this some more... 1) validateFileName is a *bad* name (should be something like "raionaliseFullPathSpecification", or whatever) - it takes full paths too, rather than just file names, and, has rightly been pointed out, simply adding '/' to the list of bad chars for the Mac messes things up. 2) The problem occurred on my build (on a Mac), when I wrote the bit to get public hublists. In 2 places (" FavoriteManager::onHttpFinished", " FavoriteManager::refresh") the hubURL is converted to a filename using validateFileName - this produces "bad" names - the url=filename contains extra '/' chars - extra folder levels to my OS, and those folders don't exist. http://hublist.hubtracker.com/hublist.xml.bz2 gets converted to... http_/hublist.hubtracker.com/hublist.xml.bz2 What I've done is... A) Invent a "urlToFileName" routine (replacing ':' and '/' with '_') B) Replace those 2 calls listed above with calls to "urlToFileName" instead. 3) Whilst you could probably fix up validateFileName to act "differently" on the actual filename part of a given path (although that might be hard since the url looks like a pretty cool path), I don't think that's the way to go. This isn't filename conversion, it's a url to filename conversion and should, imho, have its own specific routine to do that. static string urlToFileName(string tmp) { string::size_type i = 0; // remove ':' i = 0; while( (i = tmp.find(':', i)) != string::npos) { tmp[i] = '_'; i++; } // remove '/' i = 0; while( (i = tmp.find('/', i)) != string::npos) { tmp[i] = '_'; i++; } return tmp; } > yeah right - ignore that patch. :/ > > i guess validateFileName() tries to keep the path, cleaning only nested paths > and bad chars. it might need to get re-written: no need to look for "/./", > "//", etc when all '/' have been cleared. > > itinerants, are you sure it "doesn't work" on Mac? > > poy > ----- Original Message ----- > From: James Ross > To: DC++ Devel > Sent: Thursday, November 15, 2007 2:27 PM > Subject: Re: [dcplusplus-devel] ValidateFileName problem on Macintosh... > > > From: poy > Sent: Thursday, November 15, 2007 1:13 PM > To: Patches & development discussion > Subject: Re: [dcplusplus-devel] ValidateFileName problem on Macintosh... > > > little fix, not tested of course. > > as for ':', have a look at line 198 of Util.cpp. ;) > Won't the addition of "/" to the list already containing "\" mean that all > the bits of ValidateFileName which appear to be doing some path work will > never match? One of the comments even implies it will be given absolute paths, > which are never going to work if you replace "/" and "\" with "_", no? > > I guess the important question is whether ValidateFileName is expected to > accept and return a simple filename with no paths anywhere or not and, if if > paths are allowed/expected, are they meant to be preserved in the output? > > -- > James Ross > > > ------------------------------------------------------------------------------ > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > > ------------------------------------------------------------------------------ > > > _______________________________________________ > dcplusplus-devel mailing list > dcp...@li... > https://lists.sourceforge.net/lists/listinfo/dcplusplus-devel > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > dcplusplus-devel mailing list > dcp...@li... > https://lists.sourceforge.net/lists/listinfo/dcplusplus-devel |