Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid decoding for original UUencode charset #52

Closed
ecofi opened this issue May 19, 2023 · 13 comments · Fixed by #53
Closed

Invalid decoding for original UUencode charset #52

ecofi opened this issue May 19, 2023 · 13 comments · Fixed by #53
Labels
bug Something isn't working

Comments

@ecofi
Copy link

ecofi commented May 19, 2023

Hi,

I don't know if I'm using the incorrect options but I don't get UUencode working for decoding the attached string ( see attached file).
I'm using:
let buffer = UUencode().decode(str)

The string contains space and I get an error message for invalid space character. The attache sample represents an encoded binary as jpg picture.

pic_uue.txt

@UmamiAppearance
Copy link
Owner

UmamiAppearance commented May 19, 2023

The space is only part of the original charset for UUencode.

You can set this during initialization (or on the fly):

const uuencode = new UUencode("original");
let buffer = uuencode.decode(str);

I have not tested your input though. If you still have issues, just let me know.

@ecofi
Copy link
Author

ecofi commented May 20, 2023

Thank you, unfortunately it is not working. Difficult to understand the problem, tested a lot.
I put a little code together for decoding to uint8array and downloading as file :
https://jsfiddle.net/hleogr/2yuk5s34/34/

I cannot say whether the input is wrong or there is a issue with the decoder.

@UmamiAppearance
Copy link
Owner

Hi. The code looks way too complicated. As far as I can see, you feed the decoder line by line, which is not the right way to do it. Where is the UUencoded string coming from? It also contains octal escape sequences. Do you have a pure sample input?

@ecofi
Copy link
Author

ecofi commented May 20, 2023

Hi, indeed, the sample string is from a larger source that contains multiple uue encoded binaries. For simplification purpose, I only included one uue encoded string in the fiddle example. The matchAll regexp finds all uuencoded files and each is feeded as ${bincontent} to the decoder (not line by line).

@UmamiAppearance
Copy link
Owner

UmamiAppearance commented May 20, 2023

OK. I found the problem.
Actually it is immanent to the original UUencode charset. If you take a look at your fiddle example, line 6. There is a space missing at the very end of the line, which can easily get removed by editors or whatever. It is also missing in the original file. This causes the decoder to produce wrong results. I will work on a fix for the original version to add missing spaces if they not present (the very first character of a UUencoded line indicates the correct number of characters).

@UmamiAppearance UmamiAppearance changed the title I'm struggling with UUencode Ivalid decoding for oroginal UUencode charset May 20, 2023
@UmamiAppearance UmamiAppearance changed the title Ivalid decoding for oroginal UUencode charset Invalid decoding for oroginal UUencode charset May 20, 2023
@UmamiAppearance UmamiAppearance added the bug Something isn't working label May 20, 2023
@UmamiAppearance UmamiAppearance changed the title Invalid decoding for oroginal UUencode charset Invalid decoding for original UUencode charset May 20, 2023
@UmamiAppearance UmamiAppearance linked a pull request May 21, 2023 that will close this issue
@UmamiAppearance
Copy link
Owner

Give it a try now.

@ecofi
Copy link
Author

ecofi commented May 22, 2023 via email

@UmamiAppearance
Copy link
Owner

Hi. How big are those files? Do you have a real example?

@ecofi
Copy link
Author

ecofi commented May 22, 2023 via email

@ecofi
Copy link
Author

ecofi commented May 22, 2023 via email

@UmamiAppearance
Copy link
Owner

Please continue this in this new created issue: #54

@UmamiAppearance
Copy link
Owner

Updated #54

@UmamiAppearance
Copy link
Owner

There still was an issue, when spaces where missing in last encoded line. Fixed in #56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants