Bug 111760 - colon in filenames causes problems
Summary: colon in filenames causes problems
Status: RESOLVED FIXED
Alias: None
Product: kuickshow
Classification: Applications
Component: general (show other bugs)
Version: 0.8.7
Platform: unspecified Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Carsten Pfeiffer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-30 12:54 UTC by Walter Hofmann
Modified: 2007-05-29 21:11 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Walter Hofmann 2005-08-30 12:54:26 UTC
Version:           0.8.7 (using KDE 3.4.1, Debian Package 4:3.4.1-1 (3.1))
Compiler:          gcc version 3.3.6 (Debian 1:3.3.6-5)
OS:                Linux (i686) release 2.6.13-rc6

I have a PNG-File created by tvtime which kuickshow cannot open from the command line:

wh@gimli:~$ kuickshow tvtime-output-12:46:40.png
kuickshow: ERROR: : couldn't create slave : Call of Input/Output-Module not possible.
klauncher meldet: Unknown protocol "tvtime-output-12".
kuickshow:
IMLIB ERROR: Cannot load image: /tmp/kde-wh/kuickshowPqudRb.tmp
All fallbacks failed.
See /usr/share/doc/imlib2/README.fallback.
kuickshow: WARNING: ImlibWidget: can't load image /tmp/kde-wh/kuickshowPqudRb.tmp


Opening with the gui or with "kuickshow ./tvtime-output-12:46:40.png" works, though.
Comment 1 Stuart Prescott 2005-11-02 03:44:11 UTC
This is a general problem with the KDE File Save As dialogue too:

In kghostview, if I give a filename of smith2005:foo.pdf (i.e. a BibTeX publication key in standard format, which is a pretty common thing to do!) then kghostview complains:

kghostview: ERROR: : couldn't create slave : Unable to create io-slave:
klauncher said: Unknown protocol 'smith2005'.

The workaround is to preface the filename with "file:" (i.e. type the filename file:smith2005:foo.pdf in the File Save As dialogue or use kuickshow file:tvtime-output-12:46:40.png)

Now... KDE's network transparency is great, but perhaps if the protocol doesn't exist then the user could be asked if it's supposed to be a local file? (Particuarly the File Save As which just silently fails unless you happen to have run it from a konsole to see the stderr!)

Comment 2 David Faure 2007-05-29 21:09:23 UTC
SVN commit 669593 by dfaure:

Reworked KCmdLineArgs::makeURL to make "kpdf a:b" work when a:b is an existing file in the current directory
CCBUGS: 111760, 146105
Albert will backport to 3.x


 M  +14 -13    kernel/kcmdlineargs.cpp  
 M  +8 -0      tests/kcmdlineargstest.cpp  


--- trunk/KDE/kdelibs/kdecore/kernel/kcmdlineargs.cpp #669592:669593
@@ -1331,21 +1331,22 @@
 
 KUrl KCmdLineArgs::makeURL(const char *_urlArg)
 {
-   QString urlArg = QFile::decodeName(_urlArg);
-   if (!QDir::isRelativePath(urlArg))
-   {
-      KUrl result;
-      result.setPath(urlArg);
-      return result; // Absolute path.
-   }
+    const QString urlArg = QFile::decodeName(_urlArg);
+    QFileInfo fileInfo(urlArg);
+    if (!fileInfo.isRelative()) { // i.e. starts with '/', on unix
+        KUrl result;
+        result.setPath(urlArg);
+        return result; // Absolute path.
+    }
 
-   if ( !KUrl::isRelativeUrl(urlArg) )
-     return KUrl(urlArg); // Argument is a URL
+    if ( KUrl::isRelativeUrl(urlArg) || fileInfo.exists() ) {
+        KUrl result;
+        result.setPath( cwd()+'/'+urlArg );
+        result.cleanPath();
+        return result;  // Relative path
+    }
 
-   KUrl result;
-   result.setPath( cwd()+'/'+urlArg );
-   result.cleanPath();
-   return result;  // Relative path
+    return KUrl(urlArg); // Argument is a URL
 }
 
 void
--- trunk/KDE/kdelibs/kdecore/tests/kcmdlineargstest.cpp #669592:669593
@@ -83,6 +83,14 @@
    kDebug() << u << endl;
    assert(u.url() == "http://www.kde.org");
 
+   QFile file("a:b");
+   bool ok = file.open(QIODevice::WriteOnly);
+   assert(ok);
+   u = KCmdLineArgs::makeURL("a:b");
+   qDebug() << u.path();
+   assert(u.isLocalFile());
+   assert(u.path().endsWith("a:b"));
+
    args->clear(); // Free up memory.
 
 
Comment 3 Albert Astals Cid 2007-05-29 21:11:46 UTC
SVN commit 669594 by aacid:

backport SVN commit 669593 by dfaure:

Reworked KCmdLineArgs::makeURL to make "kpdf a:b" work when a:b is an existing file in the current directory

BUGS: 111760, 146105


 M  +10 -9     kcmdlineargs.cpp  


--- branches/KDE/3.5/kdelibs/kdecore/kcmdlineargs.cpp #669593:669594
@@ -1248,21 +1248,22 @@
 
 KURL KCmdLineArgs::makeURL(const char *_urlArg)
 {
-   QString urlArg = QFile::decodeName(_urlArg);
-   if (!QDir::isRelativePath(urlArg))
-   {
+   const QString urlArg = QFile::decodeName(_urlArg);
+   QFileInfo fileInfo(urlArg);
+   if (!fileInfo.isRelative()) { // i.e. starts with '/', on unix
       KURL result;
       result.setPath(urlArg);
       return result; // Absolute path.
    }
 
-   if ( !KURL::isRelativeURL(urlArg) )
-     return KURL(urlArg); // Argument is a URL
+   if ( KURL::isRelativeURL(urlArg) || fileInfo.exists() ) {
+      KURL result;
+      result.setPath( cwd()+'/'+urlArg );
+      result.cleanPath();
+      return result;  // Relative path
+   }
 
-   KURL result;
-   result.setPath( cwd()+"/"+urlArg );
-   result.cleanPath();
-   return result;  // Relative path
+   return KURL(urlArg); // Argument is a URL
 }
 
 void