Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
KIO Extras
Commits
8028db6d
Commit
8028db6d
authored
Feb 19, 2021
by
Jonathan Marten
Browse files
info: Tidy up debug messages and error reporting
parent
7ba02f78
Changes
3
Hide whitespace changes
Inline
Side-by-side
info/info.cc
View file @
8028db6d
...
...
@@ -26,44 +26,38 @@ Q_LOGGING_CATEGORY(LOG_KIO_INFO, "kio_info")
using
namespace
KIO
;
InfoProtocol
::
InfoProtocol
(
const
QByteArray
&
pool
,
const
QByteArray
&
app
)
:
SlaveBase
(
"info"
,
pool
,
app
)
,
m_page
(
""
)
,
m_node
(
""
)
{
qCDebug
(
LOG_KIO_INFO
)
<<
"InfoProtocol::InfoProtocol"
;
m_cssLocation
=
QStandardPaths
::
locate
(
QStandardPaths
::
GenericDataLocation
,
"kio_docfilter/kio_docfilter.css"
);
qCDebug
(
LOG_KIO_INFO
);
QStringList
missingFiles
;
m_cssLocation
=
QStandardPaths
::
locate
(
QStandardPaths
::
GenericDataLocation
,
"kio_docfilter/kio_docfilter.css"
);
if
(
m_cssLocation
.
isEmpty
())
missingFiles
.
append
(
"kio_docfilter/kio_docfilter.css"
);
m_perl
=
QStandardPaths
::
findExecutable
(
"perl"
);
if
(
m_perl
.
isEmpty
())
missingFiles
.
append
(
"perl"
);
m_infoScript
=
QStandardPaths
::
locate
(
QStandardPaths
::
GenericDataLocation
,
"kio_info/kde-info2html"
);
if
(
m_infoScript
.
isEmpty
())
missingFiles
.
append
(
"kio_info/kde-info2html"
);
m_infoConf
=
QStandardPaths
::
locate
(
QStandardPaths
::
GenericDataLocation
,
"kio_info/kde-info2html.conf"
);
if
(
m_infoConf
.
isEmpty
())
missingFiles
.
append
(
"kio_info/kde-info2html.conf"
);
if
(
m_perl
.
isNull
()
||
m_infoScript
.
isNull
()
||
m_infoConf
.
isNull
()
)
{
qCCritical
(
LOG_KIO_INFO
)
<<
"Critical error: Cannot locate files for HTML-conversion"
;
QString
errorStr
;
if
(
m_perl
.
isNull
()
)
{
errorStr
=
"perl."
;
}
else
{
QString
missing
=
m_infoScript
.
isNull
()
?
"kio_info/kde-info2html"
:
"kio_info/kde-info2html.conf"
;
errorStr
=
"kde-info2html"
+
i18n
(
"
\n
Unable to locate file %1 which is necessary to run this service. "
"Please check your software installation."
,
missing
);
}
error
(
KIO
::
ERR_CANNOT_LAUNCH_PROCESS
,
errorStr
);
if
(
!
missingFiles
.
isEmpty
())
{
qCCritical
(
LOG_KIO_INFO
)
<<
"Cannot locate files for HTML conversion,"
<<
qPrintable
(
missingFiles
.
join
(
' '
));
QString
errorStr
=
i18n
(
"Unable to locate files which are necessary to run this service:<br>%1<br>"
"Please check your software installation."
,
missingFiles
.
join
(
' '
));
error
(
KIO
::
ERR_SLAVE_DEFINED
,
errorStr
);
exit
();
}
qCDebug
(
LOG_KIO_INFO
)
<<
"
InfoProtocol::InfoProtocol -
done"
;
qCDebug
(
LOG_KIO_INFO
)
<<
"done"
;
}
InfoProtocol
::~
InfoProtocol
()
{
qCDebug
(
LOG_KIO_INFO
)
<<
"InfoProtocol::~InfoProtocol"
;
qCDebug
(
LOG_KIO_INFO
)
<<
"InfoProtocol::~InfoProtocol - done"
;
}
void
InfoProtocol
::
get
(
const
QUrl
&
url
)
{
qCDebug
(
LOG_KIO_INFO
)
<<
"InfoProtocol::get"
;
qCDebug
(
LOG_KIO_INFO
)
<<
"URL: "
<<
url
.
toDisplayString
()
<<
" , Path :"
<<
url
.
path
();
qCDebug
(
LOG_KIO_INFO
)
<<
"URL"
<<
url
.
toDisplayString
()
<<
"path"
<<
url
.
path
();
if
(
url
.
path
()
==
"/"
)
{
...
...
@@ -98,7 +92,7 @@ void InfoProtocol::get( const QUrl& url )
// '<' in the path looks suspicious, someone is trying info:/dir/<script>alert('xss')</script>
if
(
url
.
path
().
contains
(
'<'
))
{
error
(
KIO
::
ERR_
DOES_NOT_EXIST
,
url
.
url
());
error
(
KIO
::
ERR_
MALFORMED_URL
,
url
.
url
());
return
;
}
...
...
@@ -118,11 +112,11 @@ void InfoProtocol::get( const QUrl& url )
cmd
+=
' '
;
cmd
+=
KShell
::
quoteArg
(
m_node
);
qCDebug
(
LOG_KIO_INFO
)
<<
"cmd
:
"
<<
cmd
;
qCDebug
(
LOG_KIO_INFO
)
<<
"cmd"
<<
cmd
;
FILE
*
file
=
popen
(
QFile
::
encodeName
(
cmd
),
"r"
);
if
(
!
file
)
{
qCDebug
(
LOG_KIO_INFO
)
<<
"
InfoProtocol::get
popen failed"
;
qCDebug
(
LOG_KIO_INFO
)
<<
"popen failed"
;
error
(
ERR_CANNOT_LAUNCH_PROCESS
,
cmd
);
return
;
}
...
...
@@ -140,7 +134,7 @@ void InfoProtocol::get( const QUrl& url )
if
(
n
<
0
)
{
// ERROR
qC
Debu
g
(
LOG_KIO_INFO
)
<<
"
InfoProtocol::get ERROR
!"
;
qC
Warnin
g
(
LOG_KIO_INFO
)
<<
"
read error
!"
;
pclose
(
file
);
return
;
}
...
...
@@ -153,25 +147,23 @@ void InfoProtocol::get( const QUrl& url )
finished
();
qCDebug
(
LOG_KIO_INFO
)
<<
"
InfoProtocol::get -
done"
;
qCDebug
(
LOG_KIO_INFO
)
<<
"done"
;
}
void
InfoProtocol
::
mimetype
(
const
QUrl
&
/* url */
)
{
qCDebug
(
LOG_KIO_INFO
)
<<
"InfoProtocol::mimetype"
;
qCDebug
(
LOG_KIO_INFO
)
;
// to get rid of those "Open with" dialogs...
mimeType
(
"text/html"
);
// finish action
finished
();
qCDebug
(
LOG_KIO_INFO
)
<<
"InfoProtocol::mimetype - done"
;
}
void
InfoProtocol
::
decodeURL
(
const
QUrl
&
url
)
{
qCDebug
(
LOG_KIO_INFO
)
<<
"InfoProtocol::decodeURL"
;
qCDebug
(
LOG_KIO_INFO
)
<<
url
;
/* Notes:
*
...
...
@@ -190,18 +182,16 @@ void InfoProtocol::decodeURL( const QUrl &url )
if
(
url
==
QUrl
(
"info:/browse_by_file?special=yes"
)
)
{
m_page
=
"#special#"
;
m_node
=
"browse_by_file"
;
qCDebug
(
LOG_KIO_INFO
)
<<
"InfoProtocol::decodeURL - special - browse by file"
;
qCDebug
(
LOG_KIO_INFO
)
<<
"InfoProtocol::decodeURL - special - browse by file"
;
return
;
}
decodePath
(
url
.
path
()
);
qCDebug
(
LOG_KIO_INFO
)
<<
"InfoProtocol::decodeURL - done"
;
}
void
InfoProtocol
::
decodePath
(
QString
path
)
{
qCDebug
(
LOG_KIO_INFO
)
<<
"InfoProtocol::decodePath(-"
<<
path
<<
"-)"
;
qCDebug
(
LOG_KIO_INFO
)
<<
path
;
m_page
=
"dir"
;
//default
m_node
=
""
;
...
...
@@ -210,7 +200,7 @@ void InfoProtocol::decodePath( QString path )
if
(
'/'
==
path
[
0
])
{
path
=
path
.
mid
(
1
);
}
//qCDebug(
LOG_KIO_INFO
) << "Path: " << path;
//qCDebug(LOG_KIO_INFO) << "Path: " << path;
int
slashPos
=
path
.
indexOf
(
"/"
);
...
...
@@ -226,7 +216,7 @@ void InfoProtocol::decodePath( QString path )
// remove leading+trailing whitespace
m_node
=
path
.
right
(
path
.
length
()
-
slashPos
-
1
).
trimmed
();
qCDebug
(
LOG_KIO_INFO
)
<<
"
InfoProtocol::decodePath - done"
;
qCDebug
(
LOG_KIO_INFO
)
<<
"
-> page"
<<
m_page
<<
"node"
<<
m_node
;
}
// A minimalistic stat with only the file type
...
...
@@ -244,22 +234,18 @@ void InfoProtocol::stat( const QUrl & )
#endif
statEntry
(
uds_entry
);
finished
();
}
extern
"C"
{
int
Q_DECL_EXPORT
kdemain
(
int
argc
,
char
**
argv
);
}
int
kdemain
(
int
argc
,
char
**
argv
)
{
#ifndef QT_NO_DEBUG
QLoggingCategory
::
setFilterRules
(
QStringLiteral
(
"kio_info.debug = true"
));
#endif
QCoreApplication
app
(
argc
,
argv
);
// needed for QSocketNotifier
QCoreApplication
app
(
argc
,
argv
);
// needed for QSocketNotifier
app
.
setApplicationName
(
QLatin1String
(
"kio_info"
));
qCDebug
(
LOG_KIO_INFO
)
<<
"kio_info starting
"
<<
getpid
();
qCDebug
(
LOG_KIO_INFO
)
<<
"kio_info starting"
<<
getpid
();
if
(
argc
!=
4
)
{
...
...
info/info.h
View file @
8028db6d
...
...
@@ -8,12 +8,13 @@
Q_DECLARE_LOGGING_CATEGORY
(
LOG_KIO_INFO
)
class
InfoProtocol
:
public
KIO
::
SlaveBase
{
public:
InfoProtocol
(
const
QByteArray
&
pool
,
const
QByteArray
&
app
);
~
InfoProtocol
()
override
;
~
InfoProtocol
()
override
=
default
;
void
get
(
const
QUrl
&
url
)
override
;
void
stat
(
const
QUrl
&
url
)
override
;
...
...
info/kde-info2html
View file @
8028db6d
...
...
@@ -300,8 +300,12 @@ sub infocat {
}
$
collect=
16
if
(
m
/
START-INFO-DIR-ENTRY
/);
}
if
($
empty
)
{
$
filedesc
.=
'no description available'
;
}
#
Avoid
a
noisy
"
Broken
pipe
"
message
from
bzcat
while
(<
INFOFILE
>
) {}
close INFOFILE;
if ($empty) { $filedesc .= 'no description available'; }
$filedesc .= $infofile if ($filedesc eq "");
# Add to the hash
$LinkText{$filedesc} = "$dir/$infofile";
...
...
@@ -763,7 +767,7 @@ sub PrintByFileLink {
<
hr
width=
"80%"
/>
<p>
If you did not find what you were looking for try
<a
href=
"info:$BROWSE_BY_FILE_PATH"
>
browsing by file
</a>
to
see files from packages which
did
not update the directory.
see
info
files from packages which
may
not
have
update
d
the directory.
EOF
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment