1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-02-02 15:09:23 -05:00

[document] Show IP also for idn domains.

This commit is contained in:
Witold Filipczyk 2021-04-28 16:24:20 +02:00
parent 38d8d634f7
commit 7ba9caf227
2 changed files with 19 additions and 7 deletions

View File

@ -172,7 +172,6 @@ lookup_cmd(struct option *o, char ***argv, int *argc)
if (idname) { if (idname) {
int code = idna_to_ascii_lz(idname, &idname2, 0); int code = idna_to_ascii_lz(idname, &idname2, 0);
/* FIXME: Return NULL if it coughed? --jonas */
if (code == IDNA_SUCCESS) { if (code == IDNA_SUCCESS) {
idname = idname2; idname = idname2;
allocated = 1; allocated = 1;

View File

@ -10,6 +10,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef HAVE_IDNA_H
#include <idna.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> /* OS/2 needs this after sys/types.h */ #include <netinet/in.h> /* OS/2 needs this after sys/types.h */
@ -99,13 +103,22 @@ get_ip(struct document *document)
{ {
#ifdef HAVE_INET_NTOP #ifdef HAVE_INET_NTOP
struct uri *uri = document->uri; struct uri *uri = document->uri;
char tmp; char *host = memacpy(uri->host, uri->hostlen);
if (!uri || !uri->host || !uri->hostlen) return; if (host) {
tmp = uri->host[uri->hostlen]; #ifdef CONFIG_IDN
uri->host[uri->hostlen] = 0; char *idname;
find_host(uri->host, &document->querydns, found_dns, &document->ip, 0); int code = idna_to_ascii_lz(host, &idname, 0);
uri->host[uri->hostlen] = tmp;
if (code == IDNA_SUCCESS) {
find_host(idname, &document->querydns, found_dns, &document->ip, 0);
free(idname);
}
#else
find_host(host, &document->querydns, found_dns, &document->ip, 0);
#endif
mem_free(host);
}
#endif #endif
} }