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

Endoding problems #29

Closed
felagund opened this issue Sep 18, 2022 · 7 comments
Closed

Endoding problems #29

felagund opened this issue Sep 18, 2022 · 7 comments

Comments

@felagund
Copy link
Contributor

felagund commented Sep 18, 2022

Hello, I think I am running to similar problems as in this bug: #8

My course has non asci characters in it and it seems to be causing problems:

When I try to download the course, it says Downloading Návod ke kurzu Začínáme cvičit.

However, the folder created is named "Zač�-náme cvičit" (it should have been "í"; I cannot browse it with Dolphin).

When in include/file.functions.php I move return $filename; above the $filename = preg_replace( line, the issue disappears (I found it out by putting echo statements after each statement in the function filter_filename(`)

@sumeetweb
Copy link
Owner

Hi, @felagund. Windows does not support some special characters like
image

filter_filename function is problematic with other character encoding than English.

@felagund
Copy link
Contributor Author

felagund commented Sep 20, 2022

I am not on Windows (I am on Ubuntu).

However, my filename does not have any illegal characters, Windows work with "í" in a filename perfectly right. Indeed it is problematic, probably it should e encoding aware. I know no php so cannot really offer help (and I already downlaoded the course I was interested in, thanks!).

@sumeetweb
Copy link
Owner

sumeetweb commented Sep 20, 2022

I think the issue is with this line 21 in filter_filename
$filename = mb_strcut(pathinfo($filename, PATHINFO_FILENAME), 0, 255 - ($ext ? strlen($ext) + 1 : 0), mb_detect_encoding($filename)) . ($ext ? '.' . $ext : '');

Can you remove this line and test?

@felagund
Copy link
Contributor Author

felagund commented Sep 20, 2022

No, the problem really seems to be with the preg_replace.

Commenting out the line you suggested does not change anything. I inserted echo statemens after each functino in this function and it starts coming out garbled after preg_replace already.

@sumeetweb
Copy link
Owner

Thanks. I'm removing the preg_replace for now.

sumeetweb added a commit that referenced this issue Sep 20, 2022
@felagund
Copy link
Contributor Author

Actually, per https://stackoverflow.com/questions/19629893/does-preg-replace-change-my-character-set

when /u is added to this line:

[\x7F\xA0\xAD]|          # non-printing characters DEL, NO-BREAK SPACE, SOFT HYPHEN

so thdt it looks like this:

[\x7F\xA0\xAD]/u|          # non-printing characters DEL, NO-BREAK SPACE, SOFT HYPHEN

the problem is solved

sumeetweb added a commit that referenced this issue Sep 20, 2022
Handle unsafe characters for UTF-8
@sumeetweb
Copy link
Owner

Added it to main. Thanks again, Tomas.

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