-
Notifications
You must be signed in to change notification settings - Fork 714
Ignore invalid Unicode in pkg-config descriptions #9609
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
35884ed
Ignore invalid Unicode in pkg-config descriptions
tomsmeding fdd3e24
Add changelog entry
tomsmeding bb9f9da
cabal-install-solver: Add bounds on 'text'
tomsmeding 6d179f6
No literal ASCII values, use 'ord'
tomsmeding 6569780
Address review comments re invalid unicode from pkg-config
tomsmeding 2ec89dc
Add test for invalid unicode from pkg-config
tomsmeding 7d0d59f
Compatibility with text-1.2.5.0
tomsmeding e724111
Align imports
tomsmeding 2900ecd
Handle different exception type
tomsmeding 89a2f05
Use only POSIX shell syntax
tomsmeding 28f7082
Add invalid-input handler in pkg-config shim
tomsmeding ab8870a
Actually implement all required stuff in the pkg-config shim
tomsmeding 8057eb3
Less exception dance
tomsmeding fd66f0c
Fix shebang lines
tomsmeding 16b2fc8
Don't expect a particular representation of invalid characters
tomsmeding aeedcd0
Merge branch 'master' into pkg-config-badunicode
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module MyLibrary () where |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
packages: *.cabal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: PkgConfigParse | ||
version: 0.1 | ||
license: BSD3 | ||
author: Tom Smeding | ||
maintainer: Tom Smeding | ||
synopsis: Pkg Config Parse | ||
category: PackageTests | ||
build-type: Simple | ||
cabal-version: 2.0 | ||
|
||
description: | ||
Check that Cabal does not crash when pkg-config outputs invalid Unicode. | ||
|
||
Library | ||
pkgconfig-depends: vpl | ||
default-language: Haskell2010 | ||
build-depends: base <5.0 | ||
exposed-modules: | ||
MyLibrary |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/sh | ||
|
||
set -eu | ||
|
||
# ugly, but "good enough" for this test | ||
# This will need to be updated whenever cabal invokes pkg-config | ||
# in new ways | ||
case "$*" in | ||
'--version') | ||
echo 2.1.0 # whatever | ||
;; | ||
|
||
'--variable pc_path pkg-config') | ||
echo '.' | ||
;; | ||
|
||
'--list-all') | ||
printf 'zlib zlib - zlib compression library\n' | ||
# \256 = \xAE is the iso-8859-1 (latin-1) encoded version of U+00AE, | ||
# i.e. the "registered sign": ® | ||
# This resulted in problems, see #9608 | ||
printf 'vpl Intel\256 Video Processing Library - Accelerated video decode, encode, and frame processing capabilities on Intel\256 GPUs\n' | ||
# \360 = \xF0 is latin-1 for ð; this is orð, Icelandic for "word"/"words". | ||
printf 'or\360 Icelandic characters\n' | ||
;; | ||
|
||
'--modversion '*) | ||
shift # drop the --modversion | ||
for arg; do | ||
case "$arg" in | ||
zlib) echo 1.3; ;; # whatever | ||
vpl) echo 2.10; ;; # whatever | ||
# No entry for orð here; let's not even try to match on that | ||
*) | ||
echo >&2 "Package $arg was not found in the pkg-config search path." | ||
exit 1 | ||
esac | ||
done | ||
;; | ||
|
||
# Ignore some stuff we're not implementing | ||
'--cflags '*) ;; | ||
'--libs '*) ;; | ||
|
||
*) | ||
echo >&2 "pkg-config: unrecognised arguments $* (this is an incomplete shim)" | ||
exit 1 | ||
;; | ||
esac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# cabal v2-build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Test.Cabal.Prelude | ||
|
||
-- Test that invalid unicode in pkg-config output doesn't trip up cabal very much | ||
main = cabalTest $ do | ||
-- skipped on windows because using a script to dummy up an executable doesn't work the same. | ||
skipIfWindows | ||
cdir <- testCurrentDir `fmap` getTestEnv | ||
res <- cabal' "v2-build" ["--extra-prog-path="++cdir, "-v2"] | ||
assertOutputContains "Some pkg-config packages have names containing invalid unicode: or?" res |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
synopsis: Ignore invalid Unicode in pkg-config descriptions | ||
packages: cabal-install-solver | ||
prs: #9609 | ||
issues: #9608 | ||
|
||
description: { | ||
|
||
Previously, cabal-install would crash when `pkg-config --list-all` contained | ||
invalid Unicode. With this change, invalid unicode in package descriptions is | ||
ignored, and unparseable package names are considered nonexistent. | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation doesn't seem very nice to me, it at least should be abstracted into it's own function.
getProgramInvocationsIODataAndErrors
? Which doesn't crash when theexitCode
is notExitSuccess
Parsec
interface incabal-install-solver
)In any case I don't think all this low level logic should be inlined here, so how about a new top level function
getPkgConfigPkgList
to encapsulate it all.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using parsec to split a package list on newlines is extreme overkill. Additionally, I don't think this is a lot of logic to inline, just well documented logic. And finally its actually the bulk of the function -- the existing top level function is already the encapsulation.