X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fphp_http_url.c;h=ce09754a91874f44fe6e32f1306cdcaa131610c9;hb=3ee3d5f53712e1e91d4ffef34aa0c6e8f4f8840e;hp=3c68996689b0ce60c3b7005e63698831c95053a6;hpb=80bb9787a447fd8443b824f4b3f38ecf87eca9b6;p=m6w6%2Fext-http diff --git a/src/php_http_url.c b/src/php_http_url.c index 3c68996..ce09754 100644 --- a/src/php_http_url.c +++ b/src/php_http_url.c @@ -854,7 +854,7 @@ static ZEND_RESULT_CODE parse_userinfo(struct parse_state *state, const char *pt break; } - } while(++ptr != end); + } while(++ptr < end); state->buffer[state->offset++] = 0; @@ -947,11 +947,11 @@ static ZEND_RESULT_CODE parse_gidn_2003(struct parse_state *state, size_t prev_l int rv = -1; if (state->flags & PHP_HTTP_URL_PARSE_MBUTF8) { - rv = idna_to_ascii_8z(state->url.host, &idn, IDNA_ALLOW_UNASSIGNED|IDNA_USE_STD3_ASCII_RULES); + rv = idna_to_ascii_8z(state->url.host, &idn, IDNA_ALLOW_UNASSIGNED); } # if PHP_HTTP_HAVE_WCHAR else if (state->flags & PHP_HTTP_URL_PARSE_MBLOC) { - rv = idna_to_ascii_lz(state->url.host, &idn, IDNA_ALLOW_UNASSIGNED|IDNA_USE_STD3_ASCII_RULES); + rv = idna_to_ascii_lz(state->url.host, &idn, IDNA_ALLOW_UNASSIGNED); } # endif if (rv != IDNA_SUCCESS) { @@ -972,9 +972,7 @@ static ZEND_RESULT_CODE parse_gidn_2003(struct parse_state *state, size_t prev_l #endif #if HAVE_UIDNA_IDNTOASCII -# if PHP_HTTP_HAVE_LIBICU -# include -# else +# if !PHP_HTTP_HAVE_LIBICU typedef uint16_t UChar; typedef enum { U_ZERO_ERROR = 0 } UErrorCode; int32_t uidna_IDNToASCII(const UChar *src, int32_t srcLength, UChar *dest, int32_t destCapacity, int32_t options, void *parseError, UErrorCode *status); @@ -1003,11 +1001,11 @@ static ZEND_RESULT_CODE parse_uidn_2003(struct parse_state *state) goto error; } -# if __GNUC__ +# if __GNUC__ >= 5 # pragma GCC diagnostic ignored "-Wdeprecated-declarations" # endif ahost_len = uidna_IDNToASCII(uhost_str, uhost_len, ahost_str, 256, 3, NULL, &rc); -# if __GNUC__ +# if __GNUC__ >= 5 # pragma GCC diagnostic pop # endif @@ -1034,16 +1032,13 @@ static ZEND_RESULT_CODE parse_uidn_2003(struct parse_state *state) } #endif -#if HAVE_UIDNA_IDNTOASCII -# if PHP_HTTP_HAVE_LIBICU -# include -# endif +#if PHP_HTTP_HAVE_LIBICU && HAVE_UIDNA_NAMETOASCII_UTF8 static ZEND_RESULT_CODE parse_uidn_2008(struct parse_state *state) { char *host_ptr, *error = NULL, ebuf[64] = {0}; UErrorCode rc = U_ZERO_ERROR; UIDNAInfo info = UIDNA_INFO_INITIALIZER; - UIDNA *uidna = uidna_openUTS46(UIDNA_ALLOW_UNASSIGNED|UIDNA_USE_STD3_RULES, &rc); + UIDNA *uidna = uidna_openUTS46(UIDNA_ALLOW_UNASSIGNED, &rc); if (!uidna || U_FAILURE(rc)) { return FAILURE; @@ -1189,12 +1184,12 @@ static ZEND_RESULT_CODE parse_widn_2003(struct parse_state *state) static ZEND_RESULT_CODE parse_idna(struct parse_state *state, size_t len) { #if PHP_HTTP_HAVE_IDNA2008 - if ((state->flags & PHP_HTTP_URL_PARSE_TOIDN_2008) + if ((state->flags & PHP_HTTP_URL_PARSE_TOIDN_2008) == PHP_HTTP_URL_PARSE_TOIDN_2008 # if PHP_HTTP_HAVE_IDNA2003 - || !(state->flags & PHP_HTTP_URL_PARSE_TOIDN_2003) + || (state->flags & PHP_HTTP_URL_PARSE_TOIDN_2003) != PHP_HTTP_URL_PARSE_TOIDN_2003 # endif ) { -#if HAVE_UIDNA_NAMETOASCII_UTF8 +#if PHP_HTTP_HAVE_LIBICU && HAVE_UIDNA_NAMETOASCII_UTF8 return parse_uidn_2008(state); #elif PHP_HTTP_HAVE_LIBIDN2 return parse_gidn_2008(state, len); @@ -1205,9 +1200,9 @@ static ZEND_RESULT_CODE parse_idna(struct parse_state *state, size_t len) #endif #if PHP_HTTP_HAVE_IDNA2003 - if ((state->flags & PHP_HTTP_URL_PARSE_TOIDN_2003) + if ((state->flags & PHP_HTTP_URL_PARSE_TOIDN_2003) == PHP_HTTP_URL_PARSE_TOIDN_2003 # if PHP_HTTP_HAVE_IDNA2008 - || !(state->flags & PHP_HTTP_URL_PARSE_TOIDN_2008) + || (state->flags & PHP_HTTP_URL_PARSE_TOIDN_2008) != PHP_HTTP_URL_PARSE_TOIDN_2008 #endif ) { #if HAVE_UIDNA_IDNTOASCII @@ -1224,7 +1219,7 @@ static ZEND_RESULT_CODE parse_idna(struct parse_state *state, size_t len) return parse_widn_2003(state); #endif -#if HAVE_UIDNA_NAMETOASCII_UTF8 +#if PHP_HTTP_HAVE_LIBICU && HAVE_UIDNA_NAMETOASCII_UTF8 return parse_uidn_2008(state); #elif PHP_HTTP_HAVE_LIBIDN2 return parse_gidn_2008(state, len); @@ -1425,7 +1420,7 @@ static ZEND_RESULT_CODE parse_hostinfo(struct parse_state *state, const char *pt label = ptr; ptr += mb - 1; } - } while (++ptr != end); + } while (++ptr < end); if (!state->url.host) { len = state->offset - len; @@ -1792,7 +1787,7 @@ static const char *parse_scheme(struct parse_state *state) } state->ptr += mb - 1; } - } while (++state->ptr != state->end); + } while (++state->ptr < state->end); softfail: state->offset = 0;