mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-14 15:48:23 +02:00
2022-11-09 Fred Gleason <fredg@paravelsystems.com>
* Added a file format check to the 'Image Manager' dialog in rdadmin(1) to ensure that only JPEG or PNG formatted image files can be imported. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
db6879d6a8
commit
0c139bf849
@ -23631,3 +23631,7 @@
|
|||||||
* Updated the build package list for Ubuintu 22.04 in 'INSTALL'.
|
* Updated the build package list for Ubuintu 22.04 in 'INSTALL'.
|
||||||
2022-11-07 Fred Gleason <fredg@paravelsystems.com>
|
2022-11-07 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Fixed a regression that broke the 'make deb' target.
|
* Fixed a regression that broke the 'make deb' target.
|
||||||
|
2022-11-09 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Added a file format check to the 'Image Manager' dialog in
|
||||||
|
rdadmin(1) to ensure that only JPEG or PNG formatted image files can
|
||||||
|
be imported.
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include <rdapplication.h>
|
#include <rdapplication.h>
|
||||||
|
|
||||||
@ -1122,3 +1124,28 @@ int RDCheckReturnCode(const QString &msg,int code,int ok_value)
|
|||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString RDMimeType(const QString &filename,bool *ok)
|
||||||
|
{
|
||||||
|
QStringList args;
|
||||||
|
QString ret;
|
||||||
|
|
||||||
|
args.push_back("--mime-type");
|
||||||
|
args.push_back(filename);
|
||||||
|
QProcess *proc=new QProcess();
|
||||||
|
proc->start("/usr/bin/file",args);
|
||||||
|
proc->waitForFinished();
|
||||||
|
if((proc->exitStatus()!=QProcess::NormalExit)||(proc->exitCode()!=0)) {
|
||||||
|
*ok=false;
|
||||||
|
delete proc;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
*ok=true;
|
||||||
|
ret=QString(proc->readAllStandardOutput()).
|
||||||
|
split(":",QString::SkipEmptyParts).last().trimmed();
|
||||||
|
|
||||||
|
delete proc;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -111,6 +111,7 @@ QList<pid_t> RDGetPids(const QString &program);
|
|||||||
int RDCheckExitCode(const QString &msg,int exit_code);
|
int RDCheckExitCode(const QString &msg,int exit_code);
|
||||||
int RDCheckExitCode(RDConfig *config,const QString &msg,int exit_code);
|
int RDCheckExitCode(RDConfig *config,const QString &msg,int exit_code);
|
||||||
int RDCheckReturnCode(const QString &msg,int code,int ok_value);
|
int RDCheckReturnCode(const QString &msg,int code,int ok_value);
|
||||||
|
QString RDMimeType(const QString &filename,bool *ok);
|
||||||
|
|
||||||
|
|
||||||
#endif // RDCONF_H
|
#endif // RDCONF_H
|
||||||
|
@ -713,6 +713,19 @@ int RDFeed::importImageFile(const QString &pathname,QString *err_msg,
|
|||||||
QSize max=rda->rssSchemas()->maximumImageSize(rssSchema());
|
QSize max=rda->rssSchemas()->maximumImageSize(rssSchema());
|
||||||
*err_msg="OK";
|
*err_msg="OK";
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check the file type
|
||||||
|
//
|
||||||
|
QString mimetype=RDMimeType(pathname,&ok);
|
||||||
|
if(!ok) {
|
||||||
|
*err_msg=tr("Error validating image file.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if((mimetype!="image/jpeg")&&(mimetype!="image/png")) {
|
||||||
|
*err_msg=tr("Unsupported image file format.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Load the image
|
// Load the image
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user