diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2009-08-27 23:03:14 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2009-08-27 23:03:14 -0400 |
commit | 1536f691059e78c6b0edb885b0c87024e04f818b (patch) | |
tree | 38dc07e8ae1e4684175b550fb4937dcf7dcf1ceb /WWW | |
parent | 1a34854e5b30a5fa503ceb74bfe6214829e8da8b (diff) | |
download | lynx-snapshots-1536f691059e78c6b0edb885b0c87024e04f818b.tar.gz |
snapshot of project "lynx", label v2-8-8dev_0b
Diffstat (limited to 'WWW')
-rw-r--r-- | WWW/Library/Implementation/HTParse.c | 73 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTTP.c | 4 | ||||
-rw-r--r-- | WWW/Library/Implementation/SGML.c | 5 |
3 files changed, 75 insertions, 7 deletions
diff --git a/WWW/Library/Implementation/HTParse.c b/WWW/Library/Implementation/HTParse.c index c9bfbbf0..0505c634 100644 --- a/WWW/Library/Implementation/HTParse.c +++ b/WWW/Library/Implementation/HTParse.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTParse.c,v 1.51 2009/01/03 01:11:14 tom Exp $ + * $LynxId: HTParse.c,v 1.52 2009/08/27 18:43:30 tom Exp $ * * Parse HyperText Document Address HTParse.c * ================================ @@ -21,6 +21,10 @@ #endif /* __MINGW32__ */ #endif +#ifdef USE_IDNA +#include <idna.h> +#endif + #define HEX_ESCAPE '%' struct struct_parts { @@ -234,6 +238,58 @@ char *HTParsePort(char *host, int *portp) return result; } +#ifdef USE_IDNA +static int hex_decode(int ch) +{ + int result = 0; + + if (ch >= '0' && ch <= '9') + result = (ch - '0'); + else if (ch >= 'a' && ch <= 'f') + result = (ch - 'a') + 10; + else if (ch >= 'A' && ch <= 'F') + result = (ch - 'A') + 10; + return result; +} + +/* + * Convert in-place the given hostname to IDNA form. That requires up to 64 + * characters, and we've allowed for that, with MIN_PARSE. + */ +static void convert_to_idna(char *host) +{ + char *buffer = malloc(strlen(host) + 1); + char *output = NULL; + char *src, *dst; + int code; + + if (buffer != 0) { + for (dst = buffer, src = host; *src != '\0'; ++dst) { + int ch = *src++; + + if (ch == HEX_ESCAPE) { + int hi = hex_decode(*src++); + int lo = hex_decode(*src++); + + *dst = (hi << 4) | lo; + } else { + *dst = ch; + } + } + *dst = '\0'; + code = idna_to_ascii_8z(buffer, &output, IDNA_USE_STD3_ASCII_RULES); + if (code == IDNA_SUCCESS) { + strcpy(host, output); + free(output); + } + free(buffer); + } +} +#define MIN_PARSE 80 +#else +#define MIN_PARSE 8 +#endif + /* Parse a Name relative to another name. HTParse() * -------------------------------------- * @@ -288,7 +344,7 @@ char *HTParse(const char *aName, */ len1 = strlen(aName) + 1; len2 = strlen(relatedName) + 1; - len = len1 + len2 + 8; /* Lots of space: more than enough */ + len = len1 + len2 + MIN_PARSE; /* Lots of space: more than enough */ result = tail = (char *) LYalloca(len * 2 + len1 + len2); if (result == NULL) { @@ -381,12 +437,14 @@ char *HTParse(const char *aName, * Handle the host field. */ if (wanted & PARSE_HOST) { + char *host; + if (given.host || related.host) { if (wanted & PARSE_PUNCTUATION) { *tail++ = '/'; *tail++ = '/'; } - strcpy(tail, given.host ? given.host : related.host); + strcpy(host = tail, given.host ? given.host : related.host); #define CLEAN_URLS #ifdef CLEAN_URLS /* @@ -446,6 +504,13 @@ char *HTParse(const char *aName, } } } +#ifdef USE_IDNA + /* + * Depending on locale-support, we could have a literal UTF-8 + * string as a host name, or a URL-encoded form of that. + */ + convert_to_idna(host); +#endif #endif /* CLEAN_URLS */ } } @@ -631,7 +696,7 @@ char *HTParse(const char *aName, q[0] = q[-2]; --q; } - p[0] = '%'; + p[0] = HEX_ESCAPE; p[1] = '2'; p[2] = '0'; } while ((p = strchr(result, ' ')) != 0); diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c index 3b3a2d2c..2a70cb49 100644 --- a/WWW/Library/Implementation/HTTP.c +++ b/WWW/Library/Implementation/HTTP.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTTP.c,v 1.108 2009/05/22 00:47:41 tom Exp $ + * $LynxId: HTTP.c,v 1.110 2009/08/27 00:56:00 tom Exp $ * * HyperText Tranfer Protocol - Client implementation HTTP.c * ========================== @@ -721,7 +721,7 @@ static int HTLoadHTTP(const char *arg, } #ifdef USE_GNUTLS_INCL ret = gnutls_certificate_verify_peers2(handle->gnutls_state, &tls_status); - if ((ret < 0) || tls_status) { + if (ret < 0) { int flag_continue = 1; char *msg2; diff --git a/WWW/Library/Implementation/SGML.c b/WWW/Library/Implementation/SGML.c index 35379e2d..3a388b90 100644 --- a/WWW/Library/Implementation/SGML.c +++ b/WWW/Library/Implementation/SGML.c @@ -1,5 +1,5 @@ /* - * $LynxId: SGML.c,v 1.131 2009/05/30 11:21:28 tom Exp $ + * $LynxId: SGML.c,v 1.132 2009/08/27 10:29:27 tom Exp $ * * General SGML Parser code SGML.c * ======================== @@ -1668,6 +1668,9 @@ static void SGML_character(HTStream *context, char c_in) if (clong < 256) { c = ((char) (clong & 0xff)); } + /* lynx does not use left-to-right */ + if (clong == 0x200e) + return; goto top1; } else { /* |