c0cecd0e60
1. Gnumeric has unbalanced XML tags in its doc translations. 2. itstool's XML error handler tries to print this error with context. 3. libxml2's context snipper treats the data as bytes, not UTF-8. 4. python3Packages.libxml2 casts the context to a UTF-8 Python string. 5. itstool dereferences a null pointer. This patch intervenes at #4. In https://bugzilla.gnome.org/show_bug.cgi?id=789714#c4 , upstream suggests that intervening at #3 would be better -- that each of the four copies of xmlParserPrintFileContextInternal() have four additional UTF-8 problems, one of which is that the caret indicator ought to count "unicode characters" not bytes. But to position a caret correctly, a character count is not sufficient -- this would need to use icu's BiDi logic (with fallback to doing something wrong when libxml2 is configured not to use icu) -- which makes a 'correct' fix a much larger project than this simple band-aid.
82 lines
2.9 KiB
Nix
82 lines
2.9 KiB
Nix
{ stdenv, lib, fetchurl
|
|
, zlib, xz, python, ncurses, findXMLCatalogs
|
|
, pythonSupport ? stdenv.buildPlatform == stdenv.hostPlatform
|
|
, icuSupport ? false, icu ? null
|
|
, enableShared ? stdenv.hostPlatform.libc != "msvcrt"
|
|
, enableStatic ? !enableShared,
|
|
}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
pname = "libxml2";
|
|
version = "2.9.9";
|
|
|
|
src = fetchurl {
|
|
url = "http://xmlsoft.org/sources/${pname}-${version}.tar.gz";
|
|
sha256 = "0wd881jzvqayx0ihzba29jl80k06xj9ywp16kxacdqs3064p1ywl";
|
|
};
|
|
patches = [
|
|
# Upstream bugs:
|
|
# https://bugzilla.gnome.org/show_bug.cgi?id=789714
|
|
# https://gitlab.gnome.org/GNOME/libxml2/issues/64
|
|
# Patch from https://bugzilla.opensuse.org/show_bug.cgi?id=1065270 ,
|
|
# but only the UTF-8 part.
|
|
# Can also be mitigated by fixing malformed XML inputs, such as in
|
|
# https://gitlab.gnome.org/GNOME/gnumeric/merge_requests/3 .
|
|
# Other discussion:
|
|
# https://github.com/itstool/itstool/issues/22
|
|
# https://github.com/NixOS/nixpkgs/pull/63174
|
|
# https://github.com/NixOS/nixpkgs/pull/72342
|
|
./utf8-xmlErrorFuncHandler.patch
|
|
];
|
|
|
|
outputs = [ "bin" "dev" "out" "man" "doc" ]
|
|
++ lib.optional pythonSupport "py"
|
|
++ lib.optional (enableStatic && enableShared) "static";
|
|
propagatedBuildOutputs = "out bin" + lib.optionalString pythonSupport " py";
|
|
|
|
buildInputs = lib.optional pythonSupport python
|
|
++ lib.optional (pythonSupport && python?isPy3 && python.isPy3) ncurses
|
|
# Libxml2 has an optional dependency on liblzma. However, on impure
|
|
# platforms, it may end up using that from /usr/lib, and thus lack a
|
|
# RUNPATH for that, leading to undefined references for its users.
|
|
++ lib.optional stdenv.isFreeBSD xz;
|
|
|
|
propagatedBuildInputs = [ zlib findXMLCatalogs ] ++ lib.optional icuSupport icu;
|
|
|
|
configureFlags = [
|
|
"--exec_prefix=$dev"
|
|
(lib.enableFeature enableStatic "static")
|
|
(lib.enableFeature enableShared "shared")
|
|
(lib.withFeature icuSupport "icu")
|
|
(lib.withFeatureAs pythonSupport "python" python)
|
|
];
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
doCheck = (stdenv.hostPlatform == stdenv.buildPlatform) && !stdenv.isDarwin &&
|
|
stdenv.hostPlatform.libc != "musl";
|
|
|
|
preInstall = lib.optionalString pythonSupport
|
|
''substituteInPlace python/libxml2mod.la --replace "${python}" "$py"'';
|
|
installFlags = lib.optionalString pythonSupport
|
|
''pythondir="$(py)/lib/${python.libPrefix}/site-packages"'';
|
|
|
|
postFixup = ''
|
|
moveToOutput bin/xml2-config "$dev"
|
|
moveToOutput lib/xml2Conf.sh "$dev"
|
|
moveToOutput share/man/man1 "$bin"
|
|
'' + lib.optionalString (enableStatic && enableShared) ''
|
|
moveToOutput lib/libxml2.a "$static"
|
|
'';
|
|
|
|
passthru = { inherit version; pythonSupport = pythonSupport; };
|
|
|
|
meta = {
|
|
homepage = http://xmlsoft.org/;
|
|
description = "An XML parsing library for C";
|
|
license = lib.licenses.mit;
|
|
platforms = lib.platforms.all;
|
|
maintainers = [ lib.maintainers.eelco ];
|
|
};
|
|
}
|