| Summary: | colon in filenames causes problems | ||
|---|---|---|---|
| Product: | [Unmaintained] kuickshow | Reporter: | Walter Hofmann <kdebugs-050220211414-96ad> |
| Component: | general | Assignee: | Carsten Pfeiffer <pfeiffer> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | 0.8.7 | ||
| Target Milestone: | --- | ||
| Platform: | unspecified | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Walter Hofmann
2005-08-30 12:54:26 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!) 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.
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
|