Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-12139

Sorting of files in a project's workspace should ignore case

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: core
    • Labels:
    • Environment:
      Jenkins version 1.443

      Description

      When browsing the workspace of a project the sort order of files in the directory listing depends on the case of the filenames, which is confusing and wrong.

        Activity

        Hide
        kutzi kutzi added a comment -

        Playing Advocatus Diaboli: why is it confusing and wrong?
        Why should case be ignored? What should be the sort order when there are 2 files which only differ by case?
        Do you have an example maybe to illustrate your case?

        Show
        kutzi kutzi added a comment - Playing Advocatus Diaboli: why is it confusing and wrong? Why should case be ignored? What should be the sort order when there are 2 files which only differ by case? Do you have an example maybe to illustrate your case?
        Hide
        fredg Fred G added a comment -

        Sorry, I thought this would be obvious.

        In the attached screenshot you can see the current behavior. This sort order seems odd to me if you compare it to a normal Unix directory listing, where it would be:

        a.txt
        A.txt
        b.txt
        B.txt
        c.txt
        C.txt
        

        Why is it confusing and wrong? Consider a long list of files (several hundred) with different cases (some start with capital letters, some don't) and look for a file (eg. bla.txt). You may not find it where most people would assume it.

        I don't really care which comes first (uppercase or lowercase), but looking at a Unix system again, the file starting with a lowercase character comes first. My patch does not define the order, it just ignores the case and relies on the underlying implementation.

        Apart from that, the sort order of artifacts also ignores the case. So however this may turn out, at least the sort order should be the same across all implementations of directory listings in Jenkins.

        Show
        fredg Fred G added a comment - Sorry, I thought this would be obvious. In the attached screenshot you can see the current behavior. This sort order seems odd to me if you compare it to a normal Unix directory listing, where it would be: a.txt A.txt b.txt B.txt c.txt C.txt Why is it confusing and wrong? Consider a long list of files (several hundred) with different cases (some start with capital letters, some don't) and look for a file (eg. bla.txt). You may not find it where most people would assume it. I don't really care which comes first (uppercase or lowercase), but looking at a Unix system again, the file starting with a lowercase character comes first. My patch does not define the order, it just ignores the case and relies on the underlying implementation. Apart from that, the sort order of artifacts also ignores the case. So however this may turn out, at least the sort order should be the same across all implementations of directory listings in Jenkins.
        Hide
        kutzi kutzi added a comment -

        Thanks for explaining. I wasn't aware that sorting works currently like this in Jenkins and I agree that it feels wrong.
        Actually, I think to rely on some existing 'standard' for sorting would work best - i.e. using the same default sort order as Unix systems do would be good.

        Show
        kutzi kutzi added a comment - Thanks for explaining. I wasn't aware that sorting works currently like this in Jenkins and I agree that it feels wrong. Actually, I think to rely on some existing 'standard' for sorting would work best - i.e. using the same default sort order as Unix systems do would be good.
        Hide
        fredg Fred G added a comment -
        Show
        fredg Fred G added a comment - Pull request: https://github.com/jenkinsci/jenkins/pull/333
        Hide
        oldelvet Richard Mortimer added a comment -

        I'm quite happy with making the sort order case insensitive but I should point out that the default Unix system sort order is normally case sensitive due to the use of ASCII as the default "C" character encoding.

        This can be changed at runtime according to the system locale.

        Native system "C" locale has uppercase first due to them having a lower character code in ASCII

        richm@humber:/tmp/abc$ LC_ALL=C ls -1 /tmp/abc
        A.txt
        B.txt
        C.txt
        a.txt
        b.txt
        c.txt
        

        The English/British encoding sorts in a case insensitive manner.

        richm@humber:/tmp/abc$ LC_ALL=en_GB ls -1 /tmp/abc
        a.txt
        A.txt
        b.txt
        B.txt
        c.txt
        C.txt
        
        Show
        oldelvet Richard Mortimer added a comment - I'm quite happy with making the sort order case insensitive but I should point out that the default Unix system sort order is normally case sensitive due to the use of ASCII as the default "C" character encoding. This can be changed at runtime according to the system locale. Native system "C" locale has uppercase first due to them having a lower character code in ASCII richm@humber:/tmp/abc$ LC_ALL=C ls -1 /tmp/abc A.txt B.txt C.txt a.txt b.txt c.txt The English/British encoding sorts in a case insensitive manner. richm@humber:/tmp/abc$ LC_ALL=en_GB ls -1 /tmp/abc a.txt A.txt b.txt B.txt c.txt C.txt
        Hide
        kutzi kutzi added a comment -

        Thanks Richard for pointing that out.
        What do you think: would it make sense to use the sort order of the user's locale (via the HTTP request) for sorting?

        Show
        kutzi kutzi added a comment - Thanks Richard for pointing that out. What do you think: would it make sense to use the sort order of the user's locale (via the HTTP request) for sorting?
        Hide
        fredg Fred G added a comment -

        @kutzi: So users with different locales would see different sort orders? Wouldn't it be better to use the locale of the machine (master/slave) where the directory is located? Then everyone looking at the directory listing sees the same order.

        Show
        fredg Fred G added a comment - @kutzi: So users with different locales would see different sort orders? Wouldn't it be better to use the locale of the machine (master/slave) where the directory is located? Then everyone looking at the directory listing sees the same order.
        Hide
        kutzi kutzi added a comment -

        @fred: yes, that's what I thought. Using the server locale is also an option - I think both solutions have their advantages and disadvantages

        Show
        kutzi kutzi added a comment - @fred: yes, that's what I thought. Using the server locale is also an option - I think both solutions have their advantages and disadvantages
        Hide
        oldelvet Richard Mortimer added a comment -

        @kutzi: It probably does make sense to use the user's locale from the HTTP request to sort things. However I haven't really looked into the security/practicality issues involved in doing that. I'm tempted to say that using the base locale of the machine would be wrong, unpredictable and inflexible especially in teams that are spread around the world.

        Show
        oldelvet Richard Mortimer added a comment - @kutzi: It probably does make sense to use the user's locale from the HTTP request to sort things. However I haven't really looked into the security/practicality issues involved in doing that. I'm tempted to say that using the base locale of the machine would be wrong, unpredictable and inflexible especially in teams that are spread around the world.
        Hide
        fredg Fred G added a comment -

        Seems like I opened a can of worms here. :-/

        Show
        fredg Fred G added a comment - Seems like I opened a can of worms here. :-/
        Hide
        kutzi kutzi added a comment -

        @Richard what practicality - should be easy to extract the user locale from the request and use the appropriate Collator - and especially security concerns do you have regarding using the user's locale?

        Show
        kutzi kutzi added a comment - @Richard what practicality - should be easy to extract the user locale from the request and use the appropriate Collator - and especially security concerns do you have regarding using the user's locale?
        Hide
        kutzi kutzi added a comment -

        There are but 2 things I'm concerned about regarding this issue:

        • backwards compatibility: users may complain, if the sorting order changes compared to the previous Jenkins version
        • performance: AFAIK Collator is much slower than String.compare, but that shouldn't matter as long as you don't have thousands of files
        Show
        kutzi kutzi added a comment - There are but 2 things I'm concerned about regarding this issue: backwards compatibility: users may complain, if the sorting order changes compared to the previous Jenkins version performance: AFAIK Collator is much slower than String.compare, but that shouldn't matter as long as you don't have thousands of files
        Hide
        oldelvet Richard Mortimer added a comment -

        @kutzi I don't really have any specific security issues in mind. It was really just a passing comment.

        Show
        oldelvet Richard Mortimer added a comment - @kutzi I don't really have any specific security issues in mind. It was really just a passing comment.
        Hide
        fredg Fred G added a comment -

        Concerning the backwards compatibility: If someone wants the old (wrong) sort order back it could be made configurable. I'd suggest to wait until a user has a relevant use case though.

        Show
        fredg Fred G added a comment - Concerning the backwards compatibility: If someone wants the old (wrong) sort order back it could be made configurable. I'd suggest to wait until a user has a relevant use case though.
        Hide
        scm_issue_link SCM/JIRA link daemon added a comment -

        Code changed in jenkins
        User: Christoph Kutzinski
        Path:
        changelog.html
        core/src/main/java/hudson/model/DirectoryBrowserSupport.java
        http://jenkins-ci.org/commit/jenkins/f37dcabfb87788dd6ee46966d33b7d27b57cb49e
        Log:
        [FIXED JENKINS-12139] Sort workspace file list based on request locale.

        Show
        scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Christoph Kutzinski Path: changelog.html core/src/main/java/hudson/model/DirectoryBrowserSupport.java http://jenkins-ci.org/commit/jenkins/f37dcabfb87788dd6ee46966d33b7d27b57cb49e Log: [FIXED JENKINS-12139] Sort workspace file list based on request locale.
        Hide
        dogfood dogfood added a comment -

        Integrated in jenkins_main_trunk #1389
        [FIXED JENKINS-12139] Sort workspace file list based on request locale.

        Christoph Kutzinski : f37dcabfb87788dd6ee46966d33b7d27b57cb49e
        Files :

        • core/src/main/java/hudson/model/DirectoryBrowserSupport.java
        • changelog.html
        Show
        dogfood dogfood added a comment - Integrated in jenkins_main_trunk #1389 [FIXED JENKINS-12139] Sort workspace file list based on request locale. Christoph Kutzinski : f37dcabfb87788dd6ee46966d33b7d27b57cb49e Files : core/src/main/java/hudson/model/DirectoryBrowserSupport.java changelog.html

          People

          • Assignee:
            kutzi kutzi
            Reporter:
            fredg Fred G
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: