about summary refs log tree commit diff stats
path: root/WWW
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2009-08-27 23:03:14 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2009-08-27 23:03:14 -0400
commit1536f691059e78c6b0edb885b0c87024e04f818b (patch)
tree38dc07e8ae1e4684175b550fb4937dcf7dcf1ceb /WWW
parent1a34854e5b30a5fa503ceb74bfe6214829e8da8b (diff)
downloadlynx-snapshots-1536f691059e78c6b0edb885b0c87024e04f818b.tar.gz
snapshot of project "lynx", label v2-8-8dev_0b
Diffstat (limited to 'WWW')
-rw-r--r--WWW/Library/Implementation/HTParse.c73
-rw-r--r--WWW/Library/Implementation/HTTP.c4
-rw-r--r--WWW/Library/Implementation/SGML.c5
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 {
 		    /*
' href='#n406'>406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671