Allow sending files with control bytes

This commit is contained in:
Livio Merola
2026-07-24 10:13:17 +02:00
parent 0167a9f335
commit 8da94c535e
6 changed files with 18 additions and 6 deletions
+15 -3
View File
@@ -681,7 +681,7 @@ Public Class Form1
Dim fileBytes = Await File.ReadAllBytesAsync(txtFileInvio.Text, token)
fileBytes = RemoveUtf8BomIfPresent(fileBytes)
LogFirstBytes(fileBytes)
ValidateCncTextBytes(fileBytes)
LogNonStandardCncBytes(fileBytes)
Dim blockPaced = chkInvioBlocchi.Checked
Dim terminator = If(blockPaced, Encoding.ASCII.GetBytes("%" & vbCrLf), GetTerminatorBytes())
@@ -1036,15 +1036,27 @@ Public Class Form1
End If
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
Dim value = data(i)
Dim isAllowedControl = value = &H9 OrElse value = &HA OrElse value = &HD
Dim isPrintableAscii = value >= &H20 AndAlso value <= &H7E
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
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
Private Sub SetBusy(isBusy As Boolean)
+1 -1
View File
@@ -21,7 +21,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>xn+ltMyVKq9ey0rNQnMvedxwL0v712BJKOqQDfhnUic=</dsig:DigestValue>
<dsig:DigestValue>k2O3hUFhGfgwuhFEiQcuDbJSG2zccoTiVaGjWOKs7Kw=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
Binary file not shown.
+2 -2
View File
@@ -78,7 +78,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>6ak63q3A1wBNB1K3aAaWgj8FXDjDZK9h43dSltYtzFc=</dsig:DigestValue>
<dsig:DigestValue>zDkoqd374fXylpFzzdrcE6tDrsldi7H3qk8lsY5mi8s=</dsig:DigestValue>
</hash>
</file>
<file name="LMEMoxaTransfer.exe" size="161792">
@@ -87,7 +87,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>MTWvipKrLx4Z9k9iHJsQdbI7dgO69mvCMHhKtsxpGgA=</dsig:DigestValue>
<dsig:DigestValue>NcYT1Cqbl1/pjWEqR0fuPHedbzqCZF3gF/41VgVCoZg=</dsig:DigestValue>
</hash>
</file>
</asmv1:assembly>
Binary file not shown.
Binary file not shown.