diff --git a/CMakeLists.txt b/CMakeLists.txt index 45a389f8..a22f67cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ option (USE_JS "QtScript support in Qt interface" OFF) option (XMLRPC_DAEMON "Make daemon as xmlrpc server" OFF) option (PERL_REGEX "Use pcre lib for regex in perl style" ON) option (ENABLE_STACKTRACE "Show stacktrace when program receive SIGSEGV" OFF) -option (USE_IDNA "Use libidn for punycode generation" ON) +option (USE_IDN2 "Use libidn2 for punycode generation" ON) option (JSONRPC_DAEMON "Make daemon as jsonrpc server" ON) option (USE_CLI_XMLRPC "Command line interface to control daemon via XMLRPC" OFF) option (USE_CLI_JSONRPC "Command line interface to control daemon via JSONRPC" OFF) @@ -96,9 +96,9 @@ if (PERL_REGEX) find_package(Pcre REQUIRED) endif (PERL_REGEX) -if (USE_IDNA) - find_package(IDNA REQUIRED) -endif(USE_IDNA) +if (USE_IDN2) + find_package(IDN2 REQUIRED) +endif(USE_IDN2) if (XATTR_FOUND) message (STATUS "Building with libattr support") @@ -445,7 +445,7 @@ message(STATUS "CMAKE will use these libraries (and headers) during build: aspell (headers): ${ASPELL_LIBRARIES} (${ASPELL_INCLUDE_DIR}) gettext (headers): ${GETTEXT_LIBRARIES} (${GETTEXT_INCLUDE_DIR}) pcre(cpp) (headers): ${PCRE_LIBRARIES} (${PCRE_INCLUDE_DIR}) - idna (headers): ${IDNA_LIBRARIES} (${IDNA_INCLUDE_DIR}) + idn2 (headers): ${IDN2_LIBRARIES} (${IDN2_INCLUDE_DIR}) ") configure_file("${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" diff --git a/cmake/FindIDN2.cmake b/cmake/FindIDN2.cmake index e69de29b..a46067b0 100644 --- a/cmake/FindIDN2.cmake +++ b/cmake/FindIDN2.cmake @@ -0,0 +1,40 @@ +# - Try to find GNU IDN2 library and headers +# Once done, this will define +# +# IDN2_FOUND - system has IDN2 +# IDN2_INCLUDE_DIR - the IDN2 include directories () +# IDN2_LIBRARIES - link these to use IDN2 (idn2_to_ascii_8z) + +if (IDN2_INCLUDE_DIR AND IDN2_LIBRARIES) + set(IDN2_FIND_QUIETLY TRUE) +endif (IDN2_INCLUDE_DIR AND IDN2_LIBRARIES) + +# Include dir +find_path(IDN2_INCLUDE_DIR + NAMES idn2.h +) + +# Library +find_library(IDN2_LIBRARY + NAMES idn2 +) + + +# handle the QUIETLY and REQUIRED arguments and set IDN2_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(IDN2 DEFAULT_MSG IDN2_LIBRARY IDN2_INCLUDE_DIR) + +# If we successfully found the idn2 library then add the library to the +# IDN2_LIBRARIES cmake variable otherwise set IDN2_LIBRARIES to nothing. +IF(IDN2_FOUND) + SET( IDN2_LIBRARIES ${IDN2_LIBRARY} ) +ELSE(IDN2_FOUND) + SET( IDN2_LIBRARIES ) +ENDIF(IDN2_FOUND) + + +# Lastly make it so that the IDN2_LIBRARIES and IDN2_INCLUDE_DIR variables +# only show up under the advanced options in the gui cmake applications. +MARK_AS_ADVANCED( IDN2_LIBRARIES IDN2_INCLUDE_DIR IDN2_LIBRARY) + diff --git a/cmake/FindIDNA.cmake b/cmake/FindIDNA.cmake deleted file mode 100644 index 01efc56d..00000000 --- a/cmake/FindIDNA.cmake +++ /dev/null @@ -1,40 +0,0 @@ -# - Try to find GNU IDN library and headers -# Once done, this will define -# -# IDNA_FOUND - system has IDNA -# IDNA_INCLUDE_DIR - the IDNA include directories () -# IDNA_LIBRARIES - link these to use IDNA (idna_to_ascii_8z) - -if (IDNA_INCLUDE_DIR AND IDNA_LIBRARIES) - set(IDNA_FIND_QUIETLY TRUE) -endif (IDNA_INCLUDE_DIR AND IDNA_LIBRARIES) - -# Include dir -find_path(IDNA_INCLUDE_DIR - NAMES idna.h -) - -# Library -find_library(IDNA_LIBRARY - NAMES idn -) - - -# handle the QUIETLY and REQUIRED arguments and set IDNA_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(IDNA DEFAULT_MSG IDNA_LIBRARY IDNA_INCLUDE_DIR) - -# If we successfully found the idn library then add the library to the -# IDNA_LIBRARIES cmake variable otherwise set IDNA_LIBRARIES to nothing. -IF(IDNA_FOUND) - SET( IDNA_LIBRARIES ${IDNA_LIBRARY} ) -ELSE(IDNA_FOUND) - SET( IDNA_LIBRARIES ) -ENDIF(IDNA_FOUND) - - -# Lastly make it so that the IDNA_LIBRARIES and IDNA_INCLUDE_DIR variables -# only show up under the advanced options in the gui cmake applications. -MARK_AS_ADVANCED( IDNA_LIBRARIES IDNA_INCLUDE_DIR IDNA_LIBRARY) - diff --git a/dcpp/CMakeLists.txt b/dcpp/CMakeLists.txt index e89a1524..41f8f54f 100644 --- a/dcpp/CMakeLists.txt +++ b/dcpp/CMakeLists.txt @@ -22,7 +22,7 @@ include_directories (${PROJECT_BINARY_DIR} ${OPENSSL_INCLUDE_DIR} ${GETTEXT_INCLUDE_DIR} ${LUA_INCLUDE_DIR} - ${IDNA_INCLUDE_DIR}) + ${IDN2_INCLUDE_DIR}) if (WIN32) set (LINK STATIC) @@ -64,10 +64,10 @@ if (PERL_REGEX) set(PCRE ${PCRE_LIBRARIES}) endif (PERL_REGEX) -if (USE_IDNA) +if (USE_IDN2) set_property(SOURCE ${PROJECT_SOURCE_DIR}/Util.cpp - PROPERTY COMPILE_DEFINITIONS USE_IDNA APPEND) -endif(USE_IDNA) + PROPERTY COMPILE_DEFINITIONS USE_IDN2 APPEND) +endif(USE_IDN2) if (XATTR_FOUND) set_property(SOURCE ${PROJECT_SOURCE_DIR}/HashManager.h @@ -116,7 +116,7 @@ target_link_libraries (dcpp ${LUA_LIBRARIES} ${UPNP} ${PCRE} - ${IDNA_LIBRARIES} + ${IDN2_LIBRARIES} ${XATTR_LIBRARIES} ${HAIKU_LIB} ${Boost_LIBRARIES}) diff --git a/dcpp/Util.cpp b/dcpp/Util.cpp index 1f3348c2..742b246f 100644 --- a/dcpp/Util.cpp +++ b/dcpp/Util.cpp @@ -68,8 +68,8 @@ #include "FastAlloc.h" -#ifdef USE_IDNA -#include +#ifdef USE_IDN2 +#include #endif #if defined(__APPLE__) && defined(__MACH__) @@ -671,10 +671,10 @@ void Util::decodeUrl(const string& url, string& protocol, string& host, string& query = url.substr(queryStart, queryEnd - queryStart); fragment = url.substr(fragmentStart, fragmentEnd - fragmentStart); -#ifdef USE_IDNA +#ifdef USE_IDN2 //printf("%s\n",host.c_str()); char *p; - if (idna_to_ascii_8z(host.c_str(), &p, 0) == IDNA_SUCCESS) { + if (idn2_to_ascii_8z(host.c_str(), &p, IDN2_NONTRANSITIONAL) == IDN2_OK) { host = string(p); } free(p);