Patch to have krun correctly handle scripts.
faure at kde.org
Thu May 6 20:06:30 BST 2004
On Thursday 06 May 2004 20:53, Ian Reinhart Geiser wrote:
> This is my initial attempt at helping KRun deal with scripts better. This
> patch does the following:
> 1) Checks if the url is local
> 2) Checks if the desired file has the executable bit set
> 3) Checks a list of known script mimetypes to see if its able to run it.
> The desired effect is that scripts that are remote, or are not set executable
> will be opened with what ever is their mimetype handler. This should
> insulate us from the ever popular "click on this love letter" issue other
> desktops suffer from. This also allows users who have applications written
The approach looks fine to me, but the patch introduces a discrepancy between
the files that can be executed, and what KRun::isExecutable() returns.
Konqueror's KonqMainWindow::openURL uses KRun::isExecutable() to know when
to pass a URL to KRun, in particular when no service offer is present (or to
execute instead of launching such an offer). I think that call should be replaced
with a call to your improved isExecutableFile(2 args) method, which should then
be turned into a public member.
I think that otherwise you might see differences (for executing files or not)
between systems where scripts have a service (e.g. text viewer) associated with
them and those without.
There's also the issue of konqueror's handling of "text executables", see this code
if ( !url.isLocalFile() && KonqRun::isTextExecutable( serviceType ) )
serviceType = "text/plain"; // view, don't execute
and the definition of BrowserRun::isTextExecutable in kparts/browserrun.cpp
Maybe this can be removed now that you check for +x ... To be investigated.
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the kde-core-devel