Allow sending files with control bytes
This commit is contained in:
@@ -681,7 +681,7 @@ Public Class Form1
|
|||||||
Dim fileBytes = Await File.ReadAllBytesAsync(txtFileInvio.Text, token)
|
Dim fileBytes = Await File.ReadAllBytesAsync(txtFileInvio.Text, token)
|
||||||
fileBytes = RemoveUtf8BomIfPresent(fileBytes)
|
fileBytes = RemoveUtf8BomIfPresent(fileBytes)
|
||||||
LogFirstBytes(fileBytes)
|
LogFirstBytes(fileBytes)
|
||||||
ValidateCncTextBytes(fileBytes)
|
LogNonStandardCncBytes(fileBytes)
|
||||||
Dim blockPaced = chkInvioBlocchi.Checked
|
Dim blockPaced = chkInvioBlocchi.Checked
|
||||||
Dim terminator = If(blockPaced, Encoding.ASCII.GetBytes("%" & vbCrLf), GetTerminatorBytes())
|
Dim terminator = If(blockPaced, Encoding.ASCII.GetBytes("%" & vbCrLf), GetTerminatorBytes())
|
||||||
|
|
||||||
@@ -1036,15 +1036,27 @@ Public Class Form1
|
|||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Shared Sub ValidateCncTextBytes(data As Byte())
|
Private Sub LogNonStandardCncBytes(data As Byte())
|
||||||
|
Dim firstInvalidPosition As Integer = -1
|
||||||
|
Dim firstInvalidValue As Byte = 0
|
||||||
|
Dim invalidCount As Integer
|
||||||
|
|
||||||
For i = 0 To data.Length - 1
|
For i = 0 To data.Length - 1
|
||||||
Dim value = data(i)
|
Dim value = data(i)
|
||||||
Dim isAllowedControl = value = &H9 OrElse value = &HA OrElse value = &HD
|
Dim isAllowedControl = value = &H9 OrElse value = &HA OrElse value = &HD
|
||||||
Dim isPrintableAscii = value >= &H20 AndAlso value <= &H7E
|
Dim isPrintableAscii = value >= &H20 AndAlso value <= &H7E
|
||||||
If Not isAllowedControl AndAlso Not isPrintableAscii Then
|
If Not isAllowedControl AndAlso Not isPrintableAscii Then
|
||||||
Throw New InvalidDataException($"Il file non sembra testo CNC ASCII/7 bit: byte non valido 0x{value:X2} alla posizione {i}.")
|
invalidCount += 1
|
||||||
|
If firstInvalidPosition < 0 Then
|
||||||
|
firstInvalidPosition = i
|
||||||
|
firstInvalidValue = value
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
If invalidCount > 0 Then
|
||||||
|
Log($"Avviso: trovati {invalidCount} byte di controllo/non ASCII. Primo valore 0x{firstInvalidValue:X2} alla posizione {firstInvalidPosition}. Invio comunque.")
|
||||||
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub SetBusy(isBusy As Boolean)
|
Private Sub SetBusy(isBusy As Boolean)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||||
</dsig:Transforms>
|
</dsig:Transforms>
|
||||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||||
<dsig:DigestValue>xn+ltMyVKq9ey0rNQnMvedxwL0v712BJKOqQDfhnUic=</dsig:DigestValue>
|
<dsig:DigestValue>k2O3hUFhGfgwuhFEiQcuDbJSG2zccoTiVaGjWOKs7Kw=</dsig:DigestValue>
|
||||||
</hash>
|
</hash>
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|||||||
Binary file not shown.
@@ -78,7 +78,7 @@
|
|||||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||||
</dsig:Transforms>
|
</dsig:Transforms>
|
||||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||||
<dsig:DigestValue>6ak63q3A1wBNB1K3aAaWgj8FXDjDZK9h43dSltYtzFc=</dsig:DigestValue>
|
<dsig:DigestValue>zDkoqd374fXylpFzzdrcE6tDrsldi7H3qk8lsY5mi8s=</dsig:DigestValue>
|
||||||
</hash>
|
</hash>
|
||||||
</file>
|
</file>
|
||||||
<file name="LMEMoxaTransfer.exe" size="161792">
|
<file name="LMEMoxaTransfer.exe" size="161792">
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
|
||||||
</dsig:Transforms>
|
</dsig:Transforms>
|
||||||
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
|
||||||
<dsig:DigestValue>MTWvipKrLx4Z9k9iHJsQdbI7dgO69mvCMHhKtsxpGgA=</dsig:DigestValue>
|
<dsig:DigestValue>NcYT1Cqbl1/pjWEqR0fuPHedbzqCZF3gF/41VgVCoZg=</dsig:DigestValue>
|
||||||
</hash>
|
</hash>
|
||||||
</file>
|
</file>
|
||||||
</asmv1:assembly>
|
</asmv1:assembly>
|
||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user