[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: QUrl from a string (porting KUrl constructor or KCmdLineArgs::url)
From:       Alex Merry <alex.merry () kde ! org>
Date:       2014-10-18 8:52:53
Message-ID: 9906378.HyvE16TOpQ () kyoshi
[Download RAW message or body]

On Saturday 18 October 2014 02:39:27 Kevin Kofler wrote:
> Sorry for yet another self-reply, but I'll point out that Okular currently
> uses the two-argument form, which according to the documentation is enough
> when only existing files need to be supported, but I definitely recommend
> passing the third QUrl::AssumeLocalFile argument. The reason is that I don't
> want Kompare (or most other applications that accept either a file or a
> URL) to do a hostname lookup if it's passed a nonexisting file. I think it
> doesn't make any sense to assume a URL if no http:// is given. It sends
> mistyped file names out as DNS lookups, which can even be argued to be a
> security issue.
> 
> Thus, the Kompare code will probably look like this:
> QUrl urlFromArg(const QString& arg)
> {
> #if QT_VERSION >= 0x050400
>     return QUrl::fromUserInput(arg, QDir::currentPath(),
> QUrl::AssumeLocalFile); #else
>     // Logic from QUrl::fromUserInput(QString, QString,
> UserInputResolutionOptions) return (QUrl(arg,
> QUrl::TolerantMode).isRelative() && !QDir::isAbsolutePath(arg)) ?
> QUrl::fromLocalFile(QDir::current().absoluteFilePath(arg))
>            : QUrl::fromUserInput(arg);
> 
> #endif
> }

Could you add this to the porting guide, please?

Thanks

Alex
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic