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

Fix package exporter work for paths w/ international letters #1847

Closed
wants to merge 3 commits into from

Conversation

vadi2
Copy link
Member

@vadi2 vadi2 commented Jul 25, 2018

Brief overview of PR changes/additions

Try @SlySven's suggestion from #1832 (comment) and use the ZIP_FL_ENC_UTF_8 flag when giving the zip a name.

Motivation for adding to Mudlet

Fix package exporter to work for Windows locations with international letters in them (#1790 (comment))

Other info (issues closed, discussion etc)

Fixes #1993

@Kebap
Copy link
Contributor

Kebap commented Jul 25, 2018

Using the "package exporter (experimental)" from menu, and selecting a few items to export (no additional files added), this still produces an empty 0kb XML file in the ZIP. :(

edit: win7 with non-ASCII filepath

@vadi2
Copy link
Member Author

vadi2 commented Jul 25, 2018

Try the new commit, though I am not certain it will address the issue.

@SlySven SlySven mentioned this pull request Jul 25, 2018
@Kebap
Copy link
Contributor

Kebap commented Jul 25, 2018

New commit does also fail.
WIn10 with non-ASCII user Name.

QString fname = contents[i];
if (fname == "." || fname == "..") {
QString moduleFile = contents[i];
if (moduleFile == "." || moduleFile == "..") {
Copy link
Member

Choose a reason for hiding this comment

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

This if can be removed if line 275 is changed to:

    QStringList contents = dir.entryList(QDir::NoDotAndDotDot);

However since the code here will die horribly if any directories are fed to zip_file_add it may perhaps be wise to actually use:

    QStringList contents = dir.entryList(QDir::Files);

at least until the code is fixed to handle modules with sub-directories...

@vadi2
Copy link
Member Author

vadi2 commented Aug 1, 2018

Yes, though the original problem is still there, so it doesn't really matter to move some code around... 😞

@vadi2 vadi2 self-assigned this Aug 19, 2018
@Kebap Kebap changed the title Make package manager work for paths w/ international letters WIP. Make package manager work for paths w/ international letters Sep 10, 2018
@vadi2
Copy link
Member Author

vadi2 commented Sep 25, 2018

I'll start looking into this again. I can just create a folder called тест in Windows to replicate the issue, right?

@Kebap
Copy link
Contributor

Kebap commented Sep 25, 2018

I think I tested with a non-ASCII user name (windows user) and not quite sure if your way would yield the same result.

@vadi2
Copy link
Member Author

vadi2 commented Sep 25, 2018

How do you create such a user in windows?

@vadi2
Copy link
Member Author

vadi2 commented Sep 26, 2018

First stumbling block: https://bugreports.qt.io/browse/QTBUG-70751

@vadi2 vadi2 changed the title WIP. Make package manager work for paths w/ international letters Fix package exporter work for paths w/ international letters Sep 26, 2018
@vadi2 vadi2 assigned Kebap and unassigned vadi2 Sep 26, 2018
@vadi2
Copy link
Member Author

vadi2 commented Sep 26, 2018

Try the latest build, I've found the issue.

Mudlet didn't seem to want to install the package on the non-ASCII user for me, but that's separate to the package exporter not working.

@vadi2 vadi2 added i18n & l10n internationalization and localization and removed help wanted labels Sep 26, 2018
@vadi2
Copy link
Member Author

vadi2 commented Nov 5, 2018

@Kebap ping

@Kebap
Copy link
Contributor

Kebap commented Nov 6, 2018

Exporting a package with non-ascii name will now produce output just like with a only-ascii name, however that output seems corrupt. See screenshot of test.xml file which does contain weird characters at the start, and not only readable text. Maybe it is just my text editor, but this seems wrong. Attached you can find the test.zip file with text.xml inside. Again, same contents as if the zip is created with non-ascii name, so that is working (somehow)

grafik

@Kebap Kebap assigned vadi2 and unassigned Kebap Nov 6, 2018
@vadi2
Copy link
Member Author

vadi2 commented Jan 4, 2019

@Kebap is the exporter now fixed by chance, given @SlySven's fix that was merged in?

@SlySven
Copy link
Member

SlySven commented Jan 5, 2019

Actually that text looks as though it is a sort of Pascal string formatted UTF-16 text (Pascal format means the characters of the text are preceded by an integer - 32 bit in this case - number of characters - which in this case seems to be the QChar UTF-16 units that Qt uses for text). It certainly isn't an ISO 8859-* or the UTF-8 encoding. From what I recall from poking around with the binary format details for saving and loading the map files, that is what you get when using QDataStream to write QStrings to/from a file.

<aside>Blast it, I have just spent a day upgrading my FreeBSD from 11.2-RELEASE to 12.0-RELEASE and it still includes a version 27.x PaleMoon web-browser (fork of Firefox which maintains the older more functional and less Chromelike add-ons API) whereas I need the 28.x one to get Github post previews and some other things, like Emojis, working 😢)</aside>

@Kebap Kebap assigned Kebap and unassigned vadi2 Jan 24, 2019
@Kebap
Copy link
Contributor

Kebap commented Jan 24, 2019

Vadi asked me to check if the error persists in the latest development branch, but I did not come around to it yet. That is, not this PR, but the branch named "development"

@SlySven
Copy link
Member

SlySven commented Jan 24, 2019

Sorry, I'm not following you - this PR only fixes the handling of files to put into the zip file which had names that our code could not convey into the zip library code because we were confining ourselves to a Latin1 encoding in line 289 as it is in this PR.

There are other changes which I guess have already made it into the package exporter which someone (@vadi2) will need to fixup to merge this PR into the main line code but provided you can store oddly named files in the package that is ALL that this PR addresses - so the fact that THIS PR seems to produce corrupt output is not the issue.

You did say it yourself:

Exporting a package with non-ascii name will now produce output just like with a only-ascii name,...

but as you then mentioned:

...however that output seems corrupt.

is that corruption ONLY for the non-ascii named file or is it the same for the same content in both files?

@Kebap
Copy link
Contributor

Kebap commented Jan 26, 2019

Sorry for any confusion SlySven :) Like I said above, I am not going to test this PR, but only the main development branch compared to the current release version 3.16.1 - This may indeed be confusing, as we are writing in this PR. However, this is still the best place so far, as many issues are affected and no central issue links them all together like this PR does. So this is the update.

Following tests happened on Win10. International character tested was like äöü. Did not test Asian characters or alike.

There are quite a few racing error sources here, i.e. different places where the non-ASCII letters may occur, so seperate tests seem necessary as follows:

 

  1. When starting the package exporter, user will be asked for a name. If non-ASCII is given, will export work?

Setup:

  • ASCII Username in Windows
  • ASCII Path to Package
  • ASCII Profile in Mudlet
  • Non-ASCII Package name entered

Test results:

  • current release : Package is exported fine seemingly, the zip file has contents with non-ASCII packagename.xml and config.lua, as expected. But the XML has a size of zero!
  • latest development: Package & contents exported fine.
  • this PR: not tested.

 

  1. When a user creates a new profile, they can put any name. Will non-ASCII characters affect exporting from that profile?

Setup:

  • ASCII Username in Windows
  • ASCII Path to Package
  • Non-ASCII Profile in Mudlet
  • ASCII Package name entered

Test results:

  • current release: Does not allow creation of profile with Non-ASCII names
  • latest development: Does not allow creation of profile with Non-ASCII names
  • this PR: not tested.

 

  1. When choosing which folder to export package to, user may choose a path containing a folder with non-ASCII in there somewhere, as described in Mudlet Crashing When Using Package Exporter #1790 (comment)

Setup:

  • ASCII Username in Windows
  • Non-ASCII Path to Package
  • ASCII Profile in Mudlet
  • ASCII Package name entered

Test results:

  • current release: Package is exported fine.
  • latest development: Package is exported fine.
  • this PR: not tested.

 

  1. If you install Mudlet as a non-ASCII user, Mudlet itself will live in a non-ASCII path. This destroys most Mudlet functionality and is discussed in Windows users with non-ASCII in filepath can't load LuaGlobal #1616 in more detail.

Setup:

  • Non-ASCII Username in Windows
  • ASCII Path to Package
  • ASCII Profile in Mudlet
  • ASCII Package name entered

Test results:

  • current release: Package is exported fine seemingly, the zip file has contents with non-ASCII packagename.xml and config.lua, as expected. But the XML has a size of zero!
  • latest development: Package & contents exported fine.
  • this PR: not tested.

 

Summary:

  • Test 1 and 4 - development version solves problems in current release
  • Test 2 and 3 - no problems in either version
  • This PR now seems obsolete!

@vadi2
Copy link
Member Author

vadi2 commented Jan 26, 2019

Nice - so we can close this pr, then!

@vadi2 vadi2 closed this Feb 3, 2019
@vadi2 vadi2 deleted the fix-package-expoter-i18n branch February 3, 2019 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix i18n & l10n internationalization and localization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

save profiles with non-english usernames
3 participants