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

Source name doesn't look like file name #60

Closed
janswist opened this issue Jun 6, 2023 · 8 comments
Closed

Source name doesn't look like file name #60

janswist opened this issue Jun 6, 2023 · 8 comments

Comments

@janswist
Copy link

janswist commented Jun 6, 2023

I got this error: Error: Source name "ces La esencia del cristianismo Dios es persona (jóvenes).docx" doesn't look like file name

edit: Seems like the issue is not with the name, but that there is hard cap limit of name length of 50 characters. Can we edit it somehow or at least make it bigger? 50 char names are not that rare.

Same thing with the minimum number of 3 characters - users sometimes do have like 1 char names for whatever reason :)

edit: After testing the problem is with ³ character. Exploring why is that.

@yumauri
Copy link
Owner

yumauri commented Jun 6, 2023

Hello! Wow, I didn't expect this, especially when you can use any file name, it is not required to be the same, as your real file name. Can you try something like this:

const pdf = await toPDF({
  "Christian Essence - God (Youth).docx":
    fs.createReadStream("ces La esencia del cristianismo Dios es persona (jóvenes).docx")
})

Or you are not in control of filenames?

I actually am not sure, why I put this limits back then 🤔 I'll try to loosen them and if Gotenberg is fine with new limits, I certainly will publish a fix :) In a few days, I hope

@yumauri
Copy link
Owner

yumauri commented Jun 6, 2023

Also I use regular expression

/^[\p{L}\w\s\(\).,-]+\.[A-Za-z0-9]+$/u

Character ³ doesn't pass it ...

@yumauri
Copy link
Owner

yumauri commented Jun 6, 2023

Can you show how do you use library API? Do you use file streams or file names starting with file://?

@yumauri
Copy link
Owner

yumauri commented Jun 6, 2023

I made filename checks as loose as possible, I think :) Can you try version 0.7.4?

@janswist
Copy link
Author

Sure, let me try. In the meantime from the old version (I just read your message so before update):
image

Tested. Now it works, but was strange to not accept %20 characters. Thanks for the fix!

@janswist
Copy link
Author

Can you show how do you use library API? Do you use file streams or file names starting with file://?

I use files uploaded and streams and they both has filename property.

@yumauri
Copy link
Owner

yumauri commented Jun 10, 2023

I think I was just trying to make fool-proof protection, but maybe it was not necessary.

Actually file name can contain literally any character, depending on operating system and file system. For example, in JFS file name can contain even / char. Also, on MacOS : in filenames are showed like / in Finder 🙈
image image

My main concern now is will Gotenberg be fine with those filenames? :)
Is your issue solved?

@janswist
Copy link
Author

Yes, my issue is solved - for now because one never knows what user will provide as an input 🥲 As for me, the best would be just to drop on it just because of that one reason (and to give freedom to the devs if they want to make a fool-protection). I was taken by surprise after having it on production when users got error with those exotic signs in their file names.

Regarding Gotenberg itself - I think he doesn't mind and realize that there are too many use cases to cover them all: gotenberg/gotenberg#652 but best to ask him directly, maybe even in that same issue if you like. He's quite responsive so will probably get back to you really fast :)

Thanks for supporting this js client still!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants