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

handle accented filenames on internal files #23

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

ngaretou
Copy link

@ngaretou ngaretou commented Oct 5, 2023

I had trouble with epubx handling a book and tracked it down to accented characters in the internal filenames.

See this screenshot of the internal filenames inside the file.

Screenshot 2023-10-05 at 2 06 05 PM

The problem is that the filenames are sent through Uri.decodeFull(), which throws an

Invalid argument(s): Illegal percent encoding in URI

on encountering an accent.

I put some code in that checked for the error and if there was an error on Uri.decodeFull returns the fileName with no change.

The problem with what I added is that it does not cover the case that you have accented chars and encoded url filenames, but I thought it could be a start of something eventually useful. It is covering me on these filenames which do have accents but no spaces etc that Uri.decodeFull() helps with.

//Accented characters throw a Invalid argument(s): Illegal percent encoding in URI on Uri.decodeFull.
//By checking if it throws an error and returning the filename again if so, you can use accented chars in
//epub internal filenames.
String accentedFileChecker(String incomingFileName) {
Copy link

@jasmeet0817 jasmeet0817 Nov 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be simpler:

String decodeFileName(String incomingFileName) {
try {
return Uri.decodeFull(incomingFileName);
} catch (e) {
return incomingFileName;
}
}

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

Successfully merging this pull request may close these issues.

2 participants