Potentially breaking: Make hooks sort order locale-independent

Don't sort OCI hooks using the locale collation order; it does not
make sense for the same system-wide directory to be interpreted differently
depending on the user's LC_COLLATE setting, and the language-specific
collation order can even change over time.

Besides, the current collation order determination code has never worked
with the most common LC_COLLATE values like en_US.UTF-8.

Ideally, we would like to just order based on Unicode code points
to be reliably stable, but the existing implementation is case-insensitive,
so we are forced to rely on the unicode case mapping tables at least.

(This gives up on canonicalization and width-insensitivity, potentially
breaking users who rely on these previously documented properties.)

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač
2019-03-02 06:36:44 +01:00
parent fe79bdd07e
commit 97c9115c02
6 changed files with 15 additions and 154 deletions

View File

@ -12,7 +12,6 @@ import (
current "github.com/containers/libpod/pkg/hooks/1.0.0"
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/stretchr/testify/assert"
"golang.org/x/text/language"
)
// path is the path to an example hook executable.
@ -43,12 +42,7 @@ func TestGoodNew(t *testing.T) {
}
}
lang, err := language.Parse("und-u-va-posix")
if err != nil {
t.Fatal(err)
}
manager, err := New(ctx, []string{dir}, []string{}, lang)
manager, err := New(ctx, []string{dir}, []string{})
if err != nil {
t.Fatal(err)
}
@ -110,12 +104,7 @@ func TestBadNew(t *testing.T) {
t.Fatal(err)
}
lang, err := language.Parse("und-u-va-posix")
if err != nil {
t.Fatal(err)
}
_, err = New(ctx, []string{dir}, []string{}, lang)
_, err = New(ctx, []string{dir}, []string{})
if err == nil {
t.Fatal("unexpected success")
}