when we remove the file:/ from the argument, do the precent-encoding removal to avoid being percent-encoded more than needed

based on a patch by Albert, slightly changed + unit test by me
BUG: 207461

svn path=/trunk/KDE/kdegraphics/okular/; revision=1032944
remotes/origin/KDE/4.4
Pino Toscano 17 years ago
parent 27830a988e
commit d5dd8fce01
  1. 5
      shell/shell.cpp
  2. 13
      tests/shelltest.cpp

@ -58,7 +58,12 @@ Shell::Shell(KCmdLineArgs* args, int argIndex)
if any.
*/
QString arg = m_args->arg(argIndex);
const QString origArg = arg;
arg.replace(QRegExp("^file:/{1,3}"), "/");
if (arg != origArg)
{
arg = QString::fromUtf8(QByteArray::fromPercentEncoding(arg.toUtf8()));
}
KUrl url = KCmdLineArgs::makeURL(arg.toUtf8());
int sharpPos = -1;
if (!url.isLocalFile() || !QFile::exists(url.toLocalFile()))

@ -70,6 +70,10 @@ void ShellTest::testUrlArgs_data()
<< "foo.pdf#anchor"
<< false
<< makeUrlFromCwd( "foo.pdf", "anchor" );
QTest::newRow( "#207461" )
<< "file:///tmp/file%20with%20spaces.pdf"
<< true
<< KUrl( "file:///tmp/file%20with%20spaces.pdf" );
// non-local files
QTest::newRow( "http://kde.org/foo.pdf" )
@ -84,6 +88,10 @@ void ShellTest::testUrlArgs_data()
<< "http://kde.org/foo.pdf#anchor"
<< true
<< makeUrlFromCwd( "http://kde.org/foo.pdf", "anchor" );
QTest::newRow( "#207461" )
<< "http://homepages.inf.ed.ac.uk/mef/file%20with%20spaces.pdf"
<< true
<< KUrl( "http://homepages.inf.ed.ac.uk/mef/file%20with%20spaces.pdf" );
}
void ShellTest::testUrlArgs()
@ -93,7 +101,12 @@ void ShellTest::testUrlArgs()
QFETCH( KUrl, resUrl );
// note: below is a snippet taken from the Shell ctor
const QString origArg = arg;
arg.replace(QRegExp("^file:/{1,3}"), "/");
if (arg != origArg)
{
arg = QString::fromUtf8(QByteArray::fromPercentEncoding(arg.toUtf8()));
}
KUrl url = KCmdLineArgs::makeURL(arg.toUtf8());
int sharpPos = -1;
if (!url.isLocalFile() || !exists)

Loading…
Cancel
Save