Git Product home page Git Product logo

Comments (8)

gotson avatar gotson commented on May 23, 2024

It's covered by tests though

public void unicodeFileNamesAreDecodedProperly() throws Exception {

from junrar.

AlexisJehan avatar AlexisJehan commented on May 23, 2024

It works with the unicode.rar file, effectively:

ウニコド.txt: 67
新建文本文档.txt: 10

Maybe the file I created is encoded differently? I made it with Winrar on Windows checking the RAR4 format.

from junrar.

gotson avatar gotson commented on May 23, 2024

I cannot reproduce on my macbook, it works fine. Could it be something with how your Java is configured?

from junrar.

gotson avatar gotson commented on May 23, 2024

Would you be able to produce a minimum reproducible repo on Github, showing that it works with a previous version and fails with 7.5.4?

from junrar.

AlexisJehan avatar AlexisJehan commented on May 23, 2024

I'm using Windows 10 64 bits and Adoptium JDK 11.0.16.1+1 (I also tried Adoptium JDK 18.0.2.1+1).

Here is the reproductible repo, with my outputs in the README file: https://github.com/AlexisJehan/JunrarIssue108
(The issue appears since Junrar 7.5.3)

from junrar.

gotson avatar gotson commented on May 23, 2024

Thanks, I have a fair idea where the bug could be, but I want to perform a repro first.

from junrar.

gotson avatar gotson commented on May 23, 2024

I managed to perform a repo on Gihub CI, it only fails on Windows with your file.

Archives have both a fileName and fileNameW, where the latter is the unicode one.

On Mac in CI, we get this:

07:00:29.751 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive filename: ?.txt
07:00:29.752 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive filenameW: テ.txt
07:00:29.752 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive isUnicode: true
07:00:29.752 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive getFileName: テ.txt

And on Windows:

07:00:47.789 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive filename: ?.txt
07:00:47.789 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive filenameW: ?.txt
07:00:47.789 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive isUnicode: true
07:00:47.789 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive getFileName: ?.txt

For the existing unicode archive we had, we get something different:

On Mac:

07:00:29.770 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive filename: ウニコド.txt
07:00:29.770 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive filenameW: ウニコド.txt
07:00:29.770 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive isUnicode: true
07:00:29.770 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive getFileName: ウニコド.txt
07:00:29.771 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive filename: 新建文本文档.txt
07:00:29.775 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive filenameW: 新建文本文档.txt
07:00:29.775 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive isUnicode: true
07:00:29.775 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive getFileName: 新建文本文档.txt

On Windows:

07:00:47.789 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive filename: ウニコド.txt
07:00:47.789 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive filenameW: ????.txt
07:00:47.789 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive isUnicode: true
07:00:47.789 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive getFileName: ????.txt
07:00:47.805 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive filename: 新建文本文档.txt
07:00:47.805 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive filenameW: ??????.txt
07:00:47.805 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive isUnicode: true
07:00:47.805 [Test worker] WARN com.github.junrar.rarfile.FileHeader - Archive getFileName: ??????.txt

Additional validity checks were added in 7.5.3:

            if (!isFilenameValid(fileName)) {
                throw new CorruptHeaderException("Invalid filename: " + fileName);
            }
            if (!isFilenameValid(fileNameW)) {
                throw new CorruptHeaderException("Invalid filename: " + fileNameW);
            }
    private static boolean isFilenameValid(String filename) {
        try {
            String ignored = new File(filename).getCanonicalPath();
            return true;
        } catch (IOException e) {
            return false;
        }
    }

There's a few things i don't yet understand:

  1. why isFilenameValid fails with ?.txt but not ????.txt
  2. how the existing unicode archive manages to pass the test assertThat(names).containsExactlyInAnyOrder("新建文本文档.txt", "ウニコド.txt");

It might be an encoding issue in the console output, while internally in Java it works.

from junrar.

gotson avatar gotson commented on May 23, 2024

🎉 This issue has been resolved in v7.5.5 (Release Notes)

from junrar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.