1
0
mirror of https://github.com/ElvishArtisan/rivendell.git synced 2025-04-14 16:49:17 +02:00

2018-08-11 Fred Gleason <fredg@paravelsystems.com>

* Fixed regressions in 'RDFormPost' that broke audio importation.
This commit is contained in:
Fred Gleason 2018-08-12 01:18:14 +00:00
parent 3d99fb9a87
commit c92bfd2f6c
3 changed files with 32 additions and 36 deletions

@ -17365,3 +17365,5 @@
2018-08-11 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in rddbmgr(8) that could cause segfaults when
determining the current schema verion.
2018-08-11 Fred Gleason <fredg@paravelsystems.com>
* Fixed regressions in 'RDFormPost' that broke audio importation.

@ -24,14 +24,11 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <syslog.h>
#include <rdconf.h>
#include <rdweb.h>
#include <rdformpost.h>
//Added by qt3to4:
#include <Q3TextStream>
RDFormPost::RDFormPost(RDFormPost::Encoding encoding,unsigned maxsize,
bool auto_delete)
@ -506,25 +503,17 @@ void RDFormPost::LoadUrlEncoding(char first)
void RDFormPost::LoadMultipartEncoding(char first)
{
//
// Create Stream Readers
// Create Stream Reader
//
if((post_stream=fdopen(0,"r"))==NULL) {
post_error=RDFormPost::ErrorInternal;
return;
}
QFile *file=new QFile();
if(!file->open(QIODevice::ReadOnly,post_stream)) {
delete file;
post_error=RDFormPost::ErrorInternal;
return;
}
post_text_reader=new Q3TextStream(file);
post_text_reader->setEncoding(Q3TextStream::UnicodeUTF8);
//
// Get Separator Line
//
post_separator=first+post_text_reader->readLine();
post_separator=first+QString::fromUtf8(GetLine()).trimmed();
//
// Read Mime Parts
@ -539,10 +528,6 @@ void RDFormPost::LoadMultipartEncoding(char first)
post_values[name]=value;
post_filenames[name]=is_file;
} while(again);
delete post_text_reader;
delete file;
post_error=RDFormPost::ErrorOk;
}
@ -560,7 +545,8 @@ bool RDFormPost::GetMimePart(QString *name,QString *value,bool *is_file)
// Headers
//
do {
line=post_text_reader->readLine();
// line=post_text_reader->readLine();
line=QString::fromUtf8(GetLine());
QStringList f0=line.split(":");
if(f0.size()==2) {
if(f0[0].lower()=="content-disposition") {
@ -580,30 +566,28 @@ bool RDFormPost::GetMimePart(QString *name,QString *value,bool *is_file)
}
}
}
} while(!line.stripWhiteSpace().isEmpty());
} while(!line.trimmed().isEmpty());
//
// Value
//
if(*is_file) {
char *data=NULL;
size_t n=0;
n=getline(&data,&n,post_stream);
line=QString(data).stripWhiteSpace();
QByteArray data;
data=GetLine();
line=QString::fromUtf8(data).trimmed();
while(!line.contains(post_separator)) {
write(fd,data,n);
n=getline(&data,&n,post_stream);
line=QString(data).stripWhiteSpace();
write(fd,data,data.length());
data=GetLine();
line=QString::fromUtf8(data).trimmed();
}
free(data);
}
else {
line=post_text_reader->readLine();
while(!line.contains(post_separator)) {
line=QString::fromUtf8(GetLine());
while((!line.isEmpty())&&(!line.contains(post_separator))) {
*value+=line;
line=post_text_reader->readLine();
line=QString::fromUtf8(GetLine());
}
*value=value->trimmed();
}
if(fd>=0) {
@ -611,5 +595,17 @@ bool RDFormPost::GetMimePart(QString *name,QString *value,bool *is_file)
close(fd);
}
return line.right(2)!="--";
return line.trimmed().right(2)!="--";
}
QByteArray RDFormPost::GetLine() const
{
char *data=NULL;
size_t n=0;
n=getline(&data,&n,post_stream);
QByteArray ret(data,n);
free(data);
return ret;
}

@ -2,7 +2,7 @@
//
// Handle POST data from an HTML form.
//
// (C) Copyright 2009,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2009-2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -26,7 +26,6 @@
#include <qdatastream.h>
#include <qstring.h>
#include <qstringlist.h>
#include <q3textstream.h>
#include <qvariant.h>
#include <qhostaddress.h>
@ -67,6 +66,7 @@ class RDFormPost
void LoadUrlEncoding(char first);
void LoadMultipartEncoding(char first);
bool GetMimePart(QString *name,QString *value,bool *is_file);
QByteArray GetLine() const;
QHostAddress post_client_address;
RDFormPost::Encoding post_encoding;
RDFormPost::Error post_error;
@ -77,10 +77,8 @@ class RDFormPost
unsigned post_content_length;
QString post_content_type;
char *post_data;
QString post_separator;
FILE *post_stream;
Q3TextStream *post_text_reader;
};