Just an example, and no, the decoder isn't written by me, it's from the official yEnc web site (www.yenc.org), so I'm 100% it's right.
Both files are encoded and uploaded by the same piece of software (again, not written by me), and again, I'm 100% that software is correct as well, it's used by thousands of people on a daily basis... Both these messages, are sent through the EXACT code, as it's below... This works absolutely fine: Trigger: =ybegin part=1 line=128 size=76 name=New Text Document.txt DesFileName = (New Text Document.txt) yDecoder started... =ypart-line: =ypart begin=1 end=76 part-begin: 1 part-end : 76 Last line. Endline (76 bytes): =yend size=76 part=1 pcrc32=f00625ae Included CRC: $f00625ae - calculated CRC: $f00625ae Write part to target file (start: 0, size: 76) yDecode successful AddPart (New Text Document.txt(76).dec) [1 - 76] Complete multipart --> New Text Document.txt Decoded multipart --> New Text Document.txt This fails: Trigger: =ybegin part=1 line=128 size=77859 name=Capture.PNG DesFileName = (Capture.PNG) yDecoder started... =ypart-line: =ypart begin=1 end=77859 part-begin: 1 part-end : 77859 Last line. Endline (77862 bytes): =yend size=77859 part=1 pcrc32=083aa26d Partial message corrupt: longer than (end-begin)! yDecode failed (reason: 11) Note that the failed file has 3 extra bytes... It should end at 77859, but instead, it ends at 77862. So where does those extra three bytes come from? *completely, lost* -----Original Message----- From: Chris Knipe [mailto:sav...@savage.za.org] Sent: Thursday, September 17, 2015 10:56 PM To: 'beginners@perl.org' <beginners@perl.org> Subject: RE: reading from socket Hi All, I'm SERIOUSLY starting to cry here :-( It's been over a month since I started this thread, and it's pretty much been close to a year of me battling to get this right with perl, and yes - still not there... Running under Net::Server, I have: sub process_request { while (<STDIN>) { $_ =~ s/\r?\n$//; # Remove any instance of \r or \n from the end of the received line $_ =~ s/\t//; # Remove any instance of \t from the received line $_ =~ s/[^[:ascii:]]//g; my @Command = split(/\ /, $_); switch($Command['0']) { case m/^\bPOST\b/i { print $sock "340 Ok, send message\r\n"; my $filename = '/tmp/test.txt'; open(OUTFILE, ">", $filename); binmode(OUTFILE); binmode(STDIN); my $size=0; while (read(*STDIN, local $_, 4)) { $self->log(0,Dumper($_)); print OUTFILE $_; $size=$size+length($_); if ($_ =~ /^\.\r\n$/) { last; } } close(OUTFILE); print "240 article received\r\n"; $self->log(0,"received: " . $size); } } } } } 1) From the client, I can confirm via Wireshark, all data has been transmitted (correctly, and successfully), 2) On the server, I can confirm via tcpdump, all the data has been received (correctly, and successfully), 3) In perl, I can confirm the entire message has been received in sequence (whether it's correct or not, I do not know), Certain messages that are sent, decodes correctly (a manual decode of the file that has been written. Other messages that are sent, does not decode correctly (but the data has been transmitted and received correctly). I am able to reproduce, and have data sets of data that works, and data that doesn't work. The problem is that after the file is saved to disk, certain files can decode successfully, whilst others, does not decode correctly. Can someone *PLEASE* just help me to get this sorted out? I am even willing to go off list and pay someone to fix this for me. It's now a serious, serious issue that I need to get resolved asap, and more than likely either something very trivial that I'm overlooking, or a bug somewhere in perl / Net::Server. Yes, this is still yEnc related binary data... And a gazillion things has been tried already (a lot coming from this mailing list). I fail (really, I do), to see why SOME yEnc messages that is saved decodes correctly, and others does not. It's precisely the same code.... The only thing that I can think of is that there are certain characters in some messages that something doesn't like, which IMHO means something is manipulating / changing the data is some way or form... The above code really is simple, there's no changing of data there.... -- Chris. -----Original Message----- From: Brandon McCaig [mailto:bamcc...@gmail.com] Sent: Wednesday, August 12, 2015 8:00 PM To: Chris Knipe <sav...@savage.za.org> Cc: beginners@perl.org Subject: Re: reading from socket On Wed, Aug 12, 2015 at 12:40:29AM +0200, Chris Knipe wrote: > On Wed, Aug 12, 2015 at 12:16 AM, Chris Knipe <sav...@savage.za.org> wrote: > Looking at Data::Dumper - it actually looks like latin1 to me > *seriously > confused* > > $VAR1 = > "L\\xAF\\xF3\\xDDWJL\\x94\\xEB\\xB2\\xF8\\xE1\\xACZ\\x89Ul;\\xB7\\xD > E}1 > '\\xCA\\xC2\\xE3uZ\\xFF7\\xD2=}\\xA8q:;\@,%:_\x{286}-\\xD8\\xF8\\xF > 9E\x{2c1}5\\xD6j+Z?\\xA6\\x9F\\xEC7\\xEC\\xBB4'CNld\\xBE\\xE6=J\ > \xFDL\x{7d4}\\xF9nOz(w\\x83\\xEA\\xD6UHi\\xD5p+\\xBFa\\xADvG\\xD4*a\\ > xEA\\xBBC\\xD0\x{9631}=J\\x96 > \\xFD&\\xF9M\\\\xD\\x89g\\x9EA\\xBD5\\xB4R\\xA0\\xE5sp\\xF3\\xD2x\\x84 > \xEC\\x92y\\x91\\\x{7c1}\\xB1\\xA1\\x9C\\xB73BE\\xA9)\\xCAf\\xC8\\xE > E+\\xA1b\\x8E\\xFCM!\@\\xBE^\\xB5d"; This snippet of data looks like what I perceive the yEncoding to be. If this is the beginning of the message then perhaps the entire stream *is* yEncoded? In that case, decoding the yEnc before processing may be helpful. I don't know what protocol this is... I don't see anything in there that could be mistaken for \r or \n, though I'm not sure how yEnc works. How did you modify the loop to log this? Can you show us the updated program? > And yes - there's numerous characters in the the above that actually > didn't even make it to the email... > http://www.savage.za.org/webpics/perl-encode.png I don't remember mention of an E-mail before. What relationship does that E-mail message have to this program? Note also that you appear to be sending HTML E-mails (see the Internet for why that's evil), which could also potentially mean that what I'm reading in plain text isn't exactly what you intended to send... It all depends on your MUA. You may gain some comfort knowing what you send is what you want to send by switching to plain-text E-mails. Regards, -- Brandon McCaig <bamcc...@gmail.com> <bamcc...@castopulence.org> Castopulence Software <https://www.castopulence.org/> Blog <http://www.bambams.ca/> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }. q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.}; tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say' -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/