FSN#34974 Beter bestand tegen leeg of anderszins ongeldig bestand
svn path=/Website/trunk/; revision=28215
This commit is contained in:
@@ -48,6 +48,11 @@
|
|||||||
fileData = UploadRequest.Item("imp_file").Item("Value")
|
fileData = UploadRequest.Item("imp_file").Item("Value")
|
||||||
filepathname = UploadRequest.Item("imp_file").Item("FileName")
|
filepathname = UploadRequest.Item("imp_file").Item("FileName")
|
||||||
|
|
||||||
|
If fileData = "" Then
|
||||||
|
VB_getfile = L("lcl_imp_fileempty")
|
||||||
|
Exit Function
|
||||||
|
End If
|
||||||
|
|
||||||
safefilename = safe.filename(Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\")))
|
safefilename = safe.filename(Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\")))
|
||||||
'' Extensie controle, ook al slaan we het nooit op
|
'' Extensie controle, ook al slaan we het nooit op
|
||||||
Set re = new regexp
|
Set re = new regexp
|
||||||
|
|||||||
@@ -127,6 +127,13 @@ function impReadStream(fileStream, import_app_key, params)
|
|||||||
oZIP.Close();
|
oZIP.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !fileStream.Size ) // Leeg bestand?
|
||||||
|
{
|
||||||
|
return { success: false,
|
||||||
|
backDir: backDir, // Ongeldig bestand wel weg-moven
|
||||||
|
warning: "Import error: file is empty" };
|
||||||
|
}
|
||||||
|
|
||||||
// Altijd naar win1252 converteren, dat heeft onze database ook
|
// Altijd naar win1252 converteren, dat heeft onze database ook
|
||||||
fileStream.Position = 0;
|
fileStream.Position = 0;
|
||||||
fileStream.Type = 2; // adTypeText nu
|
fileStream.Type = 2; // adTypeText nu
|
||||||
@@ -154,7 +161,9 @@ function impReadStream(fileStream, import_app_key, params)
|
|||||||
win1252Stream.Position = 0
|
win1252Stream.Position = 0
|
||||||
if( ! source.loadXML(win1252Stream.ReadText) ) // Het bestand laden
|
if( ! source.loadXML(win1252Stream.ReadText) ) // Het bestand laden
|
||||||
{
|
{
|
||||||
return { success: false, warning: "XML error: " + source.parseError.reason + " @ " + source.parseError.line + "." + source.parseError.linepos };
|
return { success: false,
|
||||||
|
backDir: backDir, // Ongeldig bestand wel weg-moven
|
||||||
|
warning: "XML error: " + source.parseError.reason + " @ " + source.parseError.line + "." + source.parseError.linepos };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the XSLT
|
// Load the XSLT
|
||||||
@@ -165,7 +174,9 @@ function impReadStream(fileStream, import_app_key, params)
|
|||||||
style.setProperty("ProhibitDTD", false); // niet moeilijk doen over DTD's
|
style.setProperty("ProhibitDTD", false); // niet moeilijk doen over DTD's
|
||||||
if( ! style.load(xslfile) ) // De stylesheet laden
|
if( ! style.load(xslfile) ) // De stylesheet laden
|
||||||
{
|
{
|
||||||
return { success: false, warning: xslfile + "\nXSL error: " + style.parseError.reason + " @ " + style.parseError.line + "." + style.parseError.linepos };
|
return { success: false,
|
||||||
|
// backDir: backDir, // het import bestand is gewoon geldig dus laten staan tot iemand de xsl-error oplost
|
||||||
|
warning: xslfile + "\nXSL error: " + style.parseError.reason + " @ " + style.parseError.line + "." + style.parseError.linepos };
|
||||||
}
|
}
|
||||||
fileData = source.transformNode(style); // terugstoppen in de fileData string
|
fileData = source.transformNode(style); // terugstoppen in de fileData string
|
||||||
// of?: xslproc.output = win1252Stream;
|
// of?: xslproc.output = win1252Stream;
|
||||||
|
|||||||
Reference in New Issue
Block a user