From c92bfd2f6cf40c3fb909cf928126643b5a1fbeca Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Sun, 12 Aug 2018 01:18:14 +0000 Subject: [PATCH] 2018-08-11 Fred Gleason * Fixed regressions in 'RDFormPost' that broke audio importation. --- ChangeLog | 2 ++ lib/rdformpost.cpp | 60 ++++++++++++++++++++++------------------------ lib/rdformpost.h | 6 ++--- 3 files changed, 32 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1b05aa9e..a8bcc58a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17365,3 +17365,5 @@ 2018-08-11 Fred Gleason * Fixed a bug in rddbmgr(8) that could cause segfaults when determining the current schema verion. +2018-08-11 Fred Gleason + * Fixed regressions in 'RDFormPost' that broke audio importation. diff --git a/lib/rdformpost.cpp b/lib/rdformpost.cpp index 9e626893..c91c49c4 100644 --- a/lib/rdformpost.cpp +++ b/lib/rdformpost.cpp @@ -24,14 +24,11 @@ #include #include #include -#include #include #include #include -//Added by qt3to4: -#include 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; } diff --git a/lib/rdformpost.h b/lib/rdformpost.h index 0fd39254..0fcba32f 100644 --- a/lib/rdformpost.h +++ b/lib/rdformpost.h @@ -2,7 +2,7 @@ // // Handle POST data from an HTML form. // -// (C) Copyright 2009,2016 Fred Gleason +// (C) Copyright 2009-2018 Fred Gleason // // 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 #include #include -#include #include #include @@ -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; };