PDA

View Full Version : QUrl and ftp scheme parsing



mcarter
13th April 2010, 16:52
I am trying to access a user account using the ftpget example code to download a file from its local dir tree. This uses the CUrl class to parse the URL string. However, it seems to be parsing the url-path incorrectly.

If I have something like "ftp::/user:passwd@192.168.1.1/path/to/follow/FILE", I would expect the path to be "path/to/follow/FILE" but it is "/path/to/follow/FILE". This contradicts what how several other packages process the URL (wget,curl,firefox). Even the Qt Assistant doc shows that the path includes the initial '/' character, which is wrong according the the RFC1738 URL documentation.

Is there a method to retrieve the proper path? Is there anything in the works to fix this? Or do most people think this is not an issue? If it is known that QUrl will always process the url in this manner then I can at least update the internal url to remove the '/' prefix.

squidge
13th April 2010, 17:37
I always thought the "/" was path of the path to indicate to retrieve the filename based from the webroot rather than being relative to the current position on the web. Is this not the case?

mcarter
14th April 2010, 17:43
I guess that depends on your definition of web-root. I am no expert, but from what I have read and have used, the path is based on the "root" of the entity processing the scheme/protocol.

For ftp, it is based on the user login, well suppose to be. For anonymous logins the user is usually restricted to a ftp dir tree and the '/' is based on that. This is usually not the case of a login from a normal user of the system (yes, the ftp server could be configured to restrict the user to its a dir, eg his home directory). He has access to the entire system so a "/" in the path means from the root system not his local login home directory.

I believe for http access, it is based on the root dir defined by the web process, apache or the like, but again I am not an expert on that.

Back to ftp and the path, to indicate an absolute path (from the / root dir) you cannot just simply use host//path but must use host/%2Fpath, which CUrl does not seem to process properly. The %2F appears in the path.