Allow disabling unsafe implicit conversions in wxString

While we have to keep these conversions enabled by default, they are very
dangerous as they can result in silent data loss on any system not using a
locale with UTF-8 encoding, i.e. always under MSW.

Allow mitigating this by defining wxNO_UNSAFE_WXSTRING_CONV when compiling the
application code using the library, which makes these conversions invisible to
the user code, and so can be used without recompiling the library.

Also add wxUSE_UNSAFE_WXSTRING_CONV which can be set to 0 when compiling the
library to disable these conversions globally for all applications using it.

Closes #11830.
This commit is contained in:
Vadim Zeitlin
2017-02-12 00:47:35 +01:00
parent 4cc45797a1
commit e125c3b657
14 changed files with 159 additions and 1 deletions

36
configure vendored
View File

@@ -1119,6 +1119,7 @@ enable_std_containers_compat
enable_std_iostreams
enable_std_string
enable_std_string_conv_in_wxstring
enable_unsafe_conv_in_wxstring
enable_unicode
enable_utf8
enable_utf8only
@@ -2057,6 +2058,7 @@ Optional Features:
--enable-std_iostreams use standard C++ stream classes
--enable-std_string use standard C++ string classes
--enable-std_string_conv_in_wxstring provide implicit conversion to std::string in wxString
--disable-unsafe_conv_in_wxstring disable unsafe implicit conversions in wxString
--disable-unicode compile without Unicode support
--enable-utf8 use UTF-8 representation for strings (Unix only)
--enable-utf8only only support UTF-8 locales in UTF-8 build (Unix only)
@@ -5469,6 +5471,35 @@ fi
eval "$wx_cv_use_std_string_conv_in_wxstring"
enablestring=disable
defaultval=
if test -z "$defaultval"; then
if test x"$enablestring" = xdisable; then
defaultval=yes
else
defaultval=no
fi
fi
# Check whether --enable-unsafe_conv_in_wxstring was given.
if test "${enable_unsafe_conv_in_wxstring+set}" = set; then :
enableval=$enable_unsafe_conv_in_wxstring;
if test "$enableval" = yes; then
wx_cv_use_unsafe_conv_in_wxstring='wxUSE_UNSAFE_WXSTRING_CONV=yes'
else
wx_cv_use_unsafe_conv_in_wxstring='wxUSE_UNSAFE_WXSTRING_CONV=no'
fi
else
wx_cv_use_unsafe_conv_in_wxstring='wxUSE_UNSAFE_WXSTRING_CONV=${'DEFAULT_wxUSE_UNSAFE_WXSTRING_CONV":-$defaultval}"
fi
eval "$wx_cv_use_unsafe_conv_in_wxstring"
enablestring=disable
defaultval=
if test -z "$defaultval"; then
@@ -32527,6 +32558,11 @@ if test "$wxUSE_STD_STRING_CONV_IN_WXSTRING" = "yes"; then
fi
if test "$wxUSE_UNSAFE_WXSTRING_CONV" = "yes"; then
$as_echo "#define wxUSE_UNSAFE_WXSTRING_CONV 1" >>confdefs.h
fi
if test "$wxUSE_STDPATHS" = "yes"; then
$as_echo "#define wxUSE_STDPATHS 1" >>confdefs.h