2019-12-17 Fred Gleason <fredg@paravelsystems.com>

* Fixed a bug in rdexport(1) that caused output filenames containing
	multi-byte UTF-8 characters to be corrupt.
This commit is contained in:
Fred Gleason 2019-12-17 17:49:55 -05:00
parent 2b3b733c0e
commit 036f3c1c46
3 changed files with 19 additions and 14 deletions

View File

@ -19358,3 +19358,6 @@
2019-12-16 Fred Gleason <fredg@paravelsystems.com> 2019-12-16 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in rdimport(1) that caused non-Latin1 characters * Fixed a bug in rdimport(1) that caused non-Latin1 characters
to be corrupted when using standard input. to be corrupted when using standard input.
2019-12-17 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in rdexport(1) that caused output filenames containing
multi-byte UTF-8 characters to be corrupt.

View File

@ -199,7 +199,7 @@ RDAudioExport::ErrorCode RDAudioExport::runExport(const QString &username,
curl_formfree(first); curl_formfree(first);
return RDAudioExport::ErrorInternal; return RDAudioExport::ErrorInternal;
} }
if((f=fopen(conv_dst_filename,"w"))==NULL) { if((f=fopen(conv_dst_filename.toUtf8(),"w"))==NULL) {
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_formfree(first); curl_formfree(first);
return RDAudioExport::ErrorNoDestination; return RDAudioExport::ErrorNoDestination;
@ -227,7 +227,7 @@ RDAudioExport::ErrorCode RDAudioExport::runExport(const QString &username,
case CURLE_ABORTED_BY_CALLBACK: case CURLE_ABORTED_BY_CALLBACK:
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_formfree(first); curl_formfree(first);
unlink(conv_dst_filename); unlink(conv_dst_filename.toUtf8());
return RDAudioExport::ErrorAborted; return RDAudioExport::ErrorAborted;
case CURLE_UNSUPPORTED_PROTOCOL: case CURLE_UNSUPPORTED_PROTOCOL:
@ -278,7 +278,7 @@ RDAudioExport::ErrorCode RDAudioExport::runExport(const QString &username,
default: default:
ret=RDAudioExport::ErrorConverter; ret=RDAudioExport::ErrorConverter;
} }
unlink(conv_dst_filename); unlink(conv_dst_filename.toUtf8());
return ret; return ret;
} }

View File

@ -57,7 +57,7 @@ MainObject::MainObject(QObject *parent)
// //
rda=new RDApplication("rdexport","rdexport",RDEXPORT_USAGE,this); rda=new RDApplication("rdexport","rdexport",RDEXPORT_USAGE,this);
if(!rda->open(&err_msg)) { if(!rda->open(&err_msg)) {
fprintf(stderr,"rdexport: %s\n",(const char *)err_msg); fprintf(stderr,"rdexport: %s\n",(const char *)err_msg.toUtf8());
exit(1); exit(1);
} }
@ -153,7 +153,7 @@ MainObject::MainObject(QObject *parent)
} }
if(!ok) { if(!ok) {
fprintf(stderr,"rdexport: unknown format \"%s\"\n", fprintf(stderr,"rdexport: unknown format \"%s\"\n",
(const char *)export_format); (const char *)export_format.toUtf8());
exit(256); exit(256);
} }
rda->cmdSwitch()->setProcessed(i,true); rda->cmdSwitch()->setProcessed(i,true);
@ -198,7 +198,7 @@ MainObject::MainObject(QObject *parent)
} }
if(!rda->cmdSwitch()->processed(i)) { if(!rda->cmdSwitch()->processed(i)) {
fprintf(stderr,"rdrepld: unknown command option \"%s\"\n", fprintf(stderr,"rdrepld: unknown command option \"%s\"\n",
(const char *)rda->cmdSwitch()->key(i)); (const char *)rda->cmdSwitch()->key(i).toUtf8());
exit(2); exit(2);
} }
} }
@ -227,7 +227,7 @@ MainObject::MainObject(QObject *parent)
str+=bad_groups[i]+", "; str+=bad_groups[i]+", ";
} }
str=str.left(str.length()-2); str=str.left(str.length()-2);
fprintf(stderr,"rdexport: %s\n",(const char *)str); fprintf(stderr,"rdexport: %s\n",(const char *)str.toUtf8());
exit(256); exit(256);
} }
@ -252,7 +252,7 @@ void MainObject::userData()
// //
if(!rda->user()->editAudio()) { if(!rda->user()->editAudio()) {
fprintf(stderr,"rdexport: user \"%s\" has no edit audio permission\n", fprintf(stderr,"rdexport: user \"%s\" has no edit audio permission\n",
(const char *)rda->user()->name()); (const char *)rda->user()->name().toUtf8());
exit(256); exit(256);
} }
@ -358,7 +358,7 @@ void MainObject::ExportCut(RDCart *cart,RDCut *cut)
if((info_err=info->runInfo(rda->user()->name(),rda->user()->password()))!= if((info_err=info->runInfo(rda->user()->name(),rda->user()->password()))!=
RDAudioInfo::ErrorOk) { RDAudioInfo::ErrorOk) {
fprintf(stderr,"rdexport: error getting cut info [%s]\n", fprintf(stderr,"rdexport: error getting cut info [%s]\n",
(const char *)RDAudioInfo::errorText(info_err)); (const char *)RDAudioInfo::errorText(info_err).toUtf8());
if(export_continue_after_error) { if(export_continue_after_error) {
return; return;
} }
@ -431,7 +431,7 @@ void MainObject::ExportCut(RDCart *cart,RDCut *cut)
if((export_err=conv->runExport(rda->user()->name(),rda->user()->password(), if((export_err=conv->runExport(rda->user()->name(),rda->user()->password(),
&conv_err))==RDAudioExport::ErrorOk) { &conv_err))==RDAudioExport::ErrorOk) {
QStringList f0=conv->destinationFile().split("/"); QStringList f0=conv->destinationFile().split("/");
printf("%s\n",(const char *)f0[f0.size()-1]); printf("%s\n",(const char *)f0.at(f0.size()-1).toUtf8());
if(export_xml) { if(export_xml) {
FILE *f=NULL; FILE *f=NULL;
f0=conv->destinationFile().split(".",QString::KeepEmptyParts); f0=conv->destinationFile().split(".",QString::KeepEmptyParts);
@ -442,15 +442,17 @@ void MainObject::ExportCut(RDCart *cart,RDCut *cut)
filename+="xml"; filename+="xml";
if((f=fopen(filename,"w"))!=NULL) { if((f=fopen(filename,"w"))!=NULL) {
fprintf(f,"%s\n", fprintf(f,"%s\n",
(const char *)cart->xml(true,true,&settings,cut->cutNumber())); (const char *)cart->xml(true,true,&settings,cut->cutNumber()).
toUtf8());
fclose(f); fclose(f);
} }
} }
} }
else { else {
fprintf(stderr,"rdexport: exporter error for output file \"%s\" [%s]\n", fprintf(stderr,"rdexport: exporter error for output file \"%s\" [%s]\n",
(const char *)conv->destinationFile(), (const char *)conv->destinationFile().toUtf8(),
(const char *)RDAudioExport::errorText(export_err,conv_err)); (const char *)RDAudioExport::errorText(export_err,conv_err).
toUtf8());
if(!export_continue_after_error) { if(!export_continue_after_error) {
exit(256); exit(256);
} }
@ -522,7 +524,7 @@ QString MainObject::SanitizePath(const QString &pathname) const
void MainObject::Verbose(const QString &msg) void MainObject::Verbose(const QString &msg)
{ {
if(export_verbose) { if(export_verbose) {
fprintf(stderr,"%s\n",(const char *)msg); fprintf(stderr,"%s\n",(const char *)msg.toUtf8());
} }
} }