mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-19 06:32:34 +02:00
2022-11-09 Fred Gleason <fredg@paravelsystems.com>
* Added an image format check to rddbmgr(8) to prevent it from attempting to generate thumbnail images from non-JPEG/PNG images. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
0c139bf849
commit
3227e340c1
@ -23635,3 +23635,6 @@
|
||||
* 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.
|
||||
2022-11-09 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added an image format check to rddbmgr(8) to prevent it from
|
||||
attempting to generate thumbnail images from non-JPEG/PNG images.
|
||||
|
@ -1149,3 +1149,33 @@ QString RDMimeType(const QString &filename,bool *ok)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
QString RDMimeType(const QByteArray &data,bool *ok)
|
||||
{
|
||||
QStringList args;
|
||||
QString ret;
|
||||
QByteArray ret_data;
|
||||
|
||||
args.push_back("--mime-type");
|
||||
args.push_back("-");
|
||||
QProcess *proc=new QProcess();
|
||||
proc->start("/usr/bin/file",args);
|
||||
proc->waitForStarted();
|
||||
proc->write(data);
|
||||
proc->closeWriteChannel();
|
||||
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;
|
||||
}
|
||||
|
@ -112,6 +112,7 @@ int RDCheckExitCode(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);
|
||||
QString RDMimeType(const QString &filename,bool *ok);
|
||||
QString RDMimeType(const QByteArray &data,bool *ok);
|
||||
|
||||
|
||||
#endif // RDCONF_H
|
||||
|
@ -19,6 +19,7 @@
|
||||
//
|
||||
|
||||
#include <rdcart.h>
|
||||
#include <rdconf.h>
|
||||
#include <rddb.h>
|
||||
#include <rdescape_string.h>
|
||||
#include <rdfeed.h>
|
||||
@ -36,6 +37,7 @@ bool MainObject::UpdateSchema(int cur_schema,int set_schema,QString *err_msg)
|
||||
QString tablename;
|
||||
RDCart *cart;
|
||||
bool length_update_required=false;
|
||||
bool ok=false;
|
||||
|
||||
if(!db_start_datetime.isNull()) {
|
||||
QDateTime now=QDateTime::currentDateTime();
|
||||
@ -11293,10 +11295,18 @@ bool MainObject::UpdateSchema(int cur_schema,int set_schema,QString *err_msg)
|
||||
}
|
||||
sql=QString("select ")+
|
||||
"`ID`,"+ // 00
|
||||
"`DATA` "+ // 01
|
||||
"`DATA`,"+ // 01
|
||||
"`FEED_KEY_NAME`," // 02
|
||||
"`DESCRIPTION` "+ // 03
|
||||
"from `FEED_IMAGES`";
|
||||
q=new RDSqlQuery(sql);
|
||||
while(q->next()) {
|
||||
QString mimetype=RDMimeType(q->value(1).toByteArray(),&ok);
|
||||
if(!ok) {
|
||||
*err_msg=tr("unable to determine image file type");
|
||||
return false;
|
||||
}
|
||||
if((mimetype=="image/jpeg")||(mimetype=="image/png")) {
|
||||
sql=QString("update `FEED_IMAGES` set ")+
|
||||
"`DATA_MID_THUMB`="+
|
||||
RDEscapeBlob(RDIMResizeImage(q->value(1).toByteArray(),
|
||||
@ -11309,6 +11319,13 @@ bool MainObject::UpdateSchema(int cur_schema,int set_schema,QString *err_msg)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,"rddbmgr: image %u:\"%s\" in RSS feed \"%s\" is not in JPEG or PNG format, skipping thumbnail generation\n",
|
||||
q->value(0).toUInt(),
|
||||
q->value(3).toString().toUtf8().constData(),
|
||||
q->value(2).toString().toUtf8().constData());
|
||||
}
|
||||
}
|
||||
delete q;
|
||||
|
||||
WriteSchemaVersion(++cur_schema);
|
||||
|
Loading…
x
Reference in New Issue
Block a user