From 5f04abe953363000594273bd6555bad731b02d6a Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 23 Jun 2014 10:26:43 +0200 Subject: [PATCH] Handle a bug in unicode module in releases R14B04 and previous The code points 16#FFFE and 16#FFFF (not assigned but valid) are considered as invalid in releases R14B04 and previous. So for these releases, the websockets testsuite always failed. This commit worked around the bug. It was fixed in OTP with the commit 34db767655: https://github.com/erlang/otp/commit/34db767655 --- configure.ac | 23 ++++++++++++++++++++++- include.mk | 4 ++++ test/t10/app_test.erl | 13 ++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 45f2500c0..3f7645e00 100644 --- a/configure.ac +++ b/configure.ac @@ -184,11 +184,32 @@ ERLANG_CHECK_ERTS ERLANG_CHECK_RELEASE dnl Check for bitstring support, introduced in R12B-5 (ERTS 5.6.5) +AC_MSG_CHECKING([for bits support]) AX_COMPARE_VERSION([${ERLANG_ERTS_VER}], [ge], [5.6.5], [bits_support="yes"], [bits_support="no"]) -AM_CONDITIONAL(BITS_SUPPORT, [test "x${bits_support}" = "xyes"]) +AC_MSG_RESULT([${bits_support}]) +BITS_SUPPORT=false +if test "x${bits_support}" = "xyes"; then + BITS_SUPPORT=true +fi +AM_CONDITIONAL(BITS_SUPPORT, [test "x${BITS_SUPPORT}" = "xtrue"]) +AC_SUBST(BITS_SUPPORT) + +dnl Unicode module was buggy for R14B04 and previous (ERTS <= 5.8.5) +AC_MSG_CHECKING([for buggy unicode module]) +AX_COMPARE_VERSION([${ERLANG_ERTS_VER}], [le], [5.8.5], + [bad_unicode="yes"], + [bad_unicode="no"]) +AC_MSG_RESULT([${bad_unicode}]) + +HAVE_BAD_UNICODE=false +if test "x${bad_unicode}" = "xyes"; then + HAVE_BAD_UNICODE=true +fi +AM_CONDITIONAL(HAVE_BAD_UNICODE, [test "x$HAVE_BAD_UNICODE" = "xtrue"]) +AC_SUBST(HAVE_BAD_UNICODE) dnl Determine directories for installation. if test "x${prefix}" != "xNONE" -a "x${ERLANG_INSTALL_LIB_DIR}" = "x"; then diff --git a/include.mk b/include.mk index 4358514b7..6d5fd67a9 100644 --- a/include.mk +++ b/include.mk @@ -24,6 +24,10 @@ ifeq ($(HAVE_INET_PARSE_STRICT_ADDRESS),true) ERLC_GENERIC_FLAGS += -DHAVE_INET_PARSE_STRICT_ADDRESS endif +ifeq ($(HAVE_BAD_UNICODE),true) + ERLC_GENERIC_FLAGS += -DHAVE_BAD_UNICODE +endif + # Local Variables: # tab-width: 8 # End: diff --git a/test/t10/app_test.erl b/test/t10/app_test.erl index aa9c8169d..599577d84 100644 --- a/test/t10/app_test.erl +++ b/test/t10/app_test.erl @@ -976,6 +976,12 @@ test_advanced_unfragmented_valid_utf8_text(BlockSz) -> do_test_unfragmented_valid_utf8("/websockets_autobahn_endpoint.yaws", BlockSz). +-ifdef(HAVE_BAD_UNICODE). +-define(BAD_UNICODE, true). +-else. +-define(BAD_UNICODE, false). +-endif. + do_test_unfragmented_valid_utf8(WSPath, BlockSz) -> Key = "dGhlIHNhbXBsZSBub25jZQ==", @@ -1004,7 +1010,12 @@ do_test_unfragmented_valid_utf8(WSPath, BlockSz) -> Fun(<<16#f0,16#90,16#80,16#80>>), Fun(<<16#7f>>), Fun(<<16#df,16#bf>>), - Fun(<<16#ef,16#bf,16#bf>>), + + case ?BAD_UNICODE of + true -> ok; + false -> Fun(<<16#ef,16#bf,16#bf>>) + end, + Fun(<<16#f4,16#8f,16#bf,16#bf>>), Fun(<<16#ed,16#9f,16#bf>>), Fun(<<16#ee,16#80,16#80>>),