mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Merge commit 'origin/elinks-0.12'
Conflicts: po/fr.po src/document/dom/renderer.c src/document/html/parser.c src/document/options.c src/document/refresh.c
This commit is contained in:
commit
13523248ed
2
NEWS
2
NEWS
@ -84,6 +84,8 @@ Miscellaneous:
|
|||||||
reloaded. See elinks-users mail from 28 Oct 2005.
|
reloaded. See elinks-users mail from 28 Oct 2005.
|
||||||
* several accesskey fixes
|
* several accesskey fixes
|
||||||
* in Lua: don't write to the string returned by lua_tostring
|
* in Lua: don't write to the string returned by lua_tostring
|
||||||
|
* minor bug 972: preserve the background color and underlining in
|
||||||
|
spaces when justifying
|
||||||
* minor bug 284: render closing bracket for HTML element SUB in the
|
* minor bug 284: render closing bracket for HTML element SUB in the
|
||||||
same line; don't let it fall to the next
|
same line; don't let it fall to the next
|
||||||
* minor: show quote characters for HTML element Q, rather than italics
|
* minor: show quote characters for HTML element Q, rather than italics
|
||||||
|
28
configure.in
28
configure.in
@ -1423,18 +1423,24 @@ if test "x$ac_cv_c_compiler_gnu" = "xyes"; then
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# GCC 4.2 snapshots warn that comparisons like &object != NULL
|
# GCC 4.2.1 warns if we use the address of an object in Boolean context:
|
||||||
# always return true. Some macros in ELinks check whether pointer
|
# warning: the address of `builtin_modules' will always evaluate as `true'
|
||||||
# arguments are NULL, and giving them addresses of named objects
|
# This hits the object_lock and foreach_module macros in particular.
|
||||||
# triggers the warning. These warnings have not revealed any real
|
# It would be okay to put something in the macros to avoid the warning,
|
||||||
# bugs, so shut them up instead of complicating the code. GCC 4.1
|
# but currently this seems to require defining parallel macros that skip
|
||||||
# does not recognize -Wno-always-true and exits with code 1 if it is
|
# the NULL check, and that's too ugly. So we instead disable the warning.
|
||||||
# given.
|
# GCC 4.2.1 needs -Wno-address, but GCC 4.2 snapshots need -Wno-always-true.
|
||||||
AC_MSG_CHECKING([whether $CC accepts -Wno-always-true])
|
# GCC 4.1.3 recognizes neither and exits with code 1 if they are given.
|
||||||
|
for warning_flag in -Wno-address -Wno-always-true; do
|
||||||
|
AC_MSG_CHECKING([whether $CC accepts $warning_flag])
|
||||||
EL_SAVE_FLAGS
|
EL_SAVE_FLAGS
|
||||||
CFLAGS="$CFLAGS -Wno-always-true"
|
CFLAGS="$CFLAGS $warning_flag"
|
||||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[AC_MSG_RESULT([yes])],[EL_RESTORE_FLAGS
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
|
||||||
AC_MSG_RESULT([no])])
|
[AC_MSG_RESULT([yes])
|
||||||
|
break],
|
||||||
|
[AC_MSG_RESULT([no])])
|
||||||
|
EL_RESTORE_FLAGS
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
|
EL_LOG_CONFIG(CFLAGS, [Compiler flags (CFLAGS)], [])
|
||||||
|
2886
po/pt_BR.po
2886
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
@ -142,16 +142,14 @@ menu_copying(struct terminal *term, void *xxx, void *xxxx)
|
|||||||
N_("Copying"), ALIGN_CENTER,
|
N_("Copying"), ALIGN_CENTER,
|
||||||
msg_text(term, N_("ELinks %s\n"
|
msg_text(term, N_("ELinks %s\n"
|
||||||
"\n"
|
"\n"
|
||||||
"(C) 1999 - 2002 Mikulas Patocka\n"
|
"%s"
|
||||||
"(C) 2001 - 2004 Petr Baudis\n"
|
"et al.\n"
|
||||||
"(C) 2002 - 2006 Jonas Fonseca\n"
|
|
||||||
"and others\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"This program is free software; you can redistribute it "
|
"This program is free software; you can redistribute it "
|
||||||
"and/or modify it under the terms of the GNU General Public "
|
"and/or modify it under the terms of the GNU General Public "
|
||||||
"License as published by the Free Software Foundation, "
|
"License as published by the Free Software Foundation, "
|
||||||
"specifically version 2 of the License."),
|
"specifically version 2 of the License."),
|
||||||
VERSION_STRING));
|
VERSION_STRING, COPYRIGHT_STRING));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ static struct menu_item view_menu[] = {
|
|||||||
|
|
||||||
static struct menu_item help_menu[] = {
|
static struct menu_item help_menu[] = {
|
||||||
/* [gettext_accelerator_context(.help_menu)] */
|
/* [gettext_accelerator_context(.help_menu)] */
|
||||||
INIT_MENU_ITEM(N_("~ELinks homepage"), NULL, ACT_MAIN_NONE, menu_url_shortcut, ELINKS_HOMEPAGE, 0),
|
INIT_MENU_ITEM(N_("~ELinks homepage"), NULL, ACT_MAIN_NONE, menu_url_shortcut, ELINKS_WEBSITE_URL, 0),
|
||||||
INIT_MENU_ITEM(N_("~Documentation"), NULL, ACT_MAIN_NONE, menu_url_shortcut, ELINKS_DOC_URL, 0),
|
INIT_MENU_ITEM(N_("~Documentation"), NULL, ACT_MAIN_NONE, menu_url_shortcut, ELINKS_DOC_URL, 0),
|
||||||
INIT_MENU_ITEM(N_("~Keys"), NULL, ACT_MAIN_NONE, menu_keys, NULL, 0),
|
INIT_MENU_ITEM(N_("~Keys"), NULL, ACT_MAIN_NONE, menu_keys, NULL, 0),
|
||||||
#ifdef CONFIG_LEDS
|
#ifdef CONFIG_LEDS
|
||||||
@ -449,6 +449,7 @@ static struct menu_item help_menu[] = {
|
|||||||
#endif
|
#endif
|
||||||
BAR_MENU_ITEM,
|
BAR_MENU_ITEM,
|
||||||
INIT_MENU_ITEM(N_("~Copying"), NULL, ACT_MAIN_NONE, menu_copying, NULL, 0),
|
INIT_MENU_ITEM(N_("~Copying"), NULL, ACT_MAIN_NONE, menu_copying, NULL, 0),
|
||||||
|
INIT_MENU_ITEM(N_("Autho~rs"), NULL, ACT_MAIN_NONE, menu_url_shortcut, ELINKS_AUTHORS_URL, 0),
|
||||||
INIT_MENU_ITEM(N_("~About"), NULL, ACT_MAIN_NONE, menu_about, NULL, 0),
|
INIT_MENU_ITEM(N_("~About"), NULL, ACT_MAIN_NONE, menu_about, NULL, 0),
|
||||||
NULL_MENU_ITEM
|
NULL_MENU_ITEM
|
||||||
};
|
};
|
||||||
|
@ -152,3 +152,17 @@ start_document_refreshes(struct session *ses)
|
|||||||
|
|
||||||
start_document_refresh(ses->doc_view->document->refresh, ses->doc_view);
|
start_document_refresh(ses->doc_view->document->refresh, ses->doc_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
start_document_refreshes(struct session *ses)
|
||||||
|
{
|
||||||
|
assert(ses);
|
||||||
|
|
||||||
|
if (!ses->doc_view
|
||||||
|
|| !ses->doc_view->document
|
||||||
|
|| !ses->doc_view->document->refresh
|
||||||
|
|| !get_opt_bool("document.browse.refresh"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
start_document_refresh(ses->doc_view->document->refresh, ses);
|
||||||
|
}
|
||||||
|
@ -497,9 +497,12 @@ render_document_frames(struct session *ses, int no_cache)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* comparison function for qsort() */
|
||||||
static int
|
static int
|
||||||
comp_links(struct link *l1, struct link *l2)
|
comp_links(const void *v1, const void *v2)
|
||||||
{
|
{
|
||||||
|
const struct link *l1 = v1, *l2 = v2;
|
||||||
|
|
||||||
assert(l1 && l2);
|
assert(l1 && l2);
|
||||||
if_assert_failed return 0;
|
if_assert_failed return 0;
|
||||||
return (l1->number - l2->number);
|
return (l1->number - l2->number);
|
||||||
@ -519,7 +522,7 @@ sort_links(struct document *document)
|
|||||||
if_assert_failed return;
|
if_assert_failed return;
|
||||||
|
|
||||||
qsort(document->links, document->nlinks, sizeof(*document->links),
|
qsort(document->links, document->nlinks, sizeof(*document->links),
|
||||||
(void *) comp_links);
|
comp_links);
|
||||||
|
|
||||||
if (!document->height) return;
|
if (!document->height) return;
|
||||||
|
|
||||||
|
@ -973,9 +973,12 @@ struct entity_cache {
|
|||||||
unsigned char str[20]; /* Suffice in any case. */
|
unsigned char str[20]; /* Suffice in any case. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* comparison function for qsort() */
|
||||||
static int
|
static int
|
||||||
hits_cmp(struct entity_cache *a, struct entity_cache *b)
|
hits_cmp(const void *v1, const void *v2)
|
||||||
{
|
{
|
||||||
|
const struct entity_cache *a = v1, *b = v2;
|
||||||
|
|
||||||
if (a->hits == b->hits) return 0;
|
if (a->hits == b->hits) return 0;
|
||||||
if (a->hits > b->hits) return -1;
|
if (a->hits > b->hits) return -1;
|
||||||
else return 1;
|
else return 1;
|
||||||
@ -1134,7 +1137,7 @@ end:
|
|||||||
/* Sort entries by hit order. */
|
/* Sort entries by hit order. */
|
||||||
if (nb_entity_cache[slen] > 1)
|
if (nb_entity_cache[slen] > 1)
|
||||||
qsort(&entity_cache[slen][0], nb_entity_cache[slen],
|
qsort(&entity_cache[slen][0], nb_entity_cache[slen],
|
||||||
sizeof(entity_cache[slen][0]), (void *) hits_cmp);
|
sizeof(entity_cache[slen][0]), hits_cmp);
|
||||||
|
|
||||||
/* Increment number of cache entries if possible.
|
/* Increment number of cache entries if possible.
|
||||||
* Else, just replace the least used entry. */
|
* Else, just replace the least used entry. */
|
||||||
|
@ -199,6 +199,128 @@ get_nntp_title(struct connection *conn)
|
|||||||
return title.source;
|
return title.source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
decode_q_segment(struct string *str, unsigned char *in, unsigned char *end)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
while ((c = *in++) != 0 && (in <= end)) {
|
||||||
|
if (c == '=') {
|
||||||
|
int d = *in++;
|
||||||
|
|
||||||
|
if (d == '\n' || !d)
|
||||||
|
break; /* drop trailing newline */
|
||||||
|
d = (unhx(d) << 4) | unhx(*in++);
|
||||||
|
add_format_to_string(str, "&#%d;", d);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == '_') /* rfc2047 4.2 (2) */
|
||||||
|
c = 0x20;
|
||||||
|
add_char_to_string(str, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
decode_b_segment(struct string *str, unsigned char *in, unsigned char *end)
|
||||||
|
{
|
||||||
|
/* Decode in..ep, possibly in-place to ot */
|
||||||
|
int c, pos = 0, acc = 0;
|
||||||
|
|
||||||
|
while ((c = *in++) != 0 && (in <= end)) {
|
||||||
|
if (c == '+')
|
||||||
|
c = 62;
|
||||||
|
else if (c == '/')
|
||||||
|
c = 63;
|
||||||
|
else if ('A' <= c && c <= 'Z')
|
||||||
|
c -= 'A';
|
||||||
|
else if ('a' <= c && c <= 'z')
|
||||||
|
c -= 'a' - 26;
|
||||||
|
else if ('0' <= c && c <= '9')
|
||||||
|
c -= '0' - 52;
|
||||||
|
else if (c == '=') {
|
||||||
|
/* padding is almost like (c == 0), except we do
|
||||||
|
* not output NUL resulting only from it;
|
||||||
|
* for now we just trust the data.
|
||||||
|
*/
|
||||||
|
c = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
continue; /* garbage */
|
||||||
|
|
||||||
|
switch (pos++) {
|
||||||
|
case 0:
|
||||||
|
acc = (c << 2);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
add_format_to_string(str, "&#%d;", (acc | (c >> 4)));
|
||||||
|
acc = (c & 15) << 4;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
add_format_to_string(str, "&#%d;", (acc | (c >> 2)));
|
||||||
|
acc = (c & 3) << 6;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
add_format_to_string(str, "&#%d;", (acc | c));
|
||||||
|
acc = pos = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_header_to_string(struct string *str, unsigned char *header)
|
||||||
|
{
|
||||||
|
unsigned char *end;
|
||||||
|
int rfc2047 = 0;
|
||||||
|
|
||||||
|
while ((end = strstr(header, "=?")) != NULL) {
|
||||||
|
int encoding;
|
||||||
|
unsigned char charset_q[256];
|
||||||
|
unsigned char *cp, *sp;
|
||||||
|
|
||||||
|
rfc2047 = 1;
|
||||||
|
|
||||||
|
if (header != end) {
|
||||||
|
add_html_to_string(str, header, end - header);
|
||||||
|
header = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* E.g.
|
||||||
|
* ep : "=?iso-2022-jp?B?GyR...?= foo"
|
||||||
|
* ep : "=?ISO-8859-1?Q?Foo=FCbar?= baz"
|
||||||
|
*/
|
||||||
|
end += 2;
|
||||||
|
cp = strchr(end, '?');
|
||||||
|
if (!cp)
|
||||||
|
break;
|
||||||
|
|
||||||
|
for (sp = end; sp < cp; sp++)
|
||||||
|
charset_q[sp - end] = tolower(*sp);
|
||||||
|
charset_q[cp - end] = 0;
|
||||||
|
encoding = tolower(cp[1]);
|
||||||
|
|
||||||
|
if (!encoding || cp[2] != '?')
|
||||||
|
break;
|
||||||
|
cp += 3;
|
||||||
|
end = strstr(cp + 3, "?=");
|
||||||
|
if (!end)
|
||||||
|
break;
|
||||||
|
if (encoding == 'b')
|
||||||
|
decode_b_segment(str, cp, end);
|
||||||
|
else if (encoding == 'q')
|
||||||
|
decode_q_segment(str, cp, end);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
|
||||||
|
header = end + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
add_html_to_string(str, header, strlen(header));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_nntp_html_start(struct string *html, struct connection *conn)
|
add_nntp_html_start(struct string *html, struct connection *conn)
|
||||||
{
|
{
|
||||||
@ -235,7 +357,9 @@ add_nntp_html_start(struct string *html, struct connection *conn)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_format_to_string(html, "<b>%s</b>: %s\n", entry, value);
|
add_format_to_string(html, "<b>%s</b>: ", entry);
|
||||||
|
add_header_to_string(html, value);
|
||||||
|
add_char_to_string(html, '\n');
|
||||||
mem_free(value);
|
mem_free(value);
|
||||||
mem_free(entry);
|
mem_free(entry);
|
||||||
}
|
}
|
||||||
@ -249,7 +373,7 @@ add_nntp_html_start(struct string *html, struct connection *conn)
|
|||||||
add_format_to_string(html,
|
add_format_to_string(html,
|
||||||
"<h2>%s</h2>\n"
|
"<h2>%s</h2>\n"
|
||||||
"<hr />\n"
|
"<hr />\n"
|
||||||
"<dl>",
|
"<ol>",
|
||||||
empty_string_or_(title));
|
empty_string_or_(title));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -275,7 +399,7 @@ add_nntp_html_end(struct string *html, struct connection *conn)
|
|||||||
case NNTP_TARGET_ARTICLE_RANGE:
|
case NNTP_TARGET_ARTICLE_RANGE:
|
||||||
case NNTP_TARGET_GROUP:
|
case NNTP_TARGET_GROUP:
|
||||||
case NNTP_TARGET_GROUPS:
|
case NNTP_TARGET_GROUPS:
|
||||||
add_to_string(html, "</dl>");
|
add_to_string(html, "</ol>");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NNTP_TARGET_QUIT:
|
case NNTP_TARGET_QUIT:
|
||||||
@ -302,16 +426,33 @@ add_nntp_html_line(struct string *html, struct connection *conn,
|
|||||||
case NNTP_TARGET_GROUP:
|
case NNTP_TARGET_GROUP:
|
||||||
case NNTP_TARGET_GROUPS:
|
case NNTP_TARGET_GROUPS:
|
||||||
{
|
{
|
||||||
unsigned char *desc = strchr(line, '\t');
|
unsigned char *field = line;
|
||||||
|
|
||||||
if (desc) {
|
line = strchr(line, '\t');
|
||||||
*desc++ = 0;
|
if (!line)
|
||||||
} else {
|
field = "";
|
||||||
desc = "";
|
else
|
||||||
|
*line++ = 0;
|
||||||
|
add_format_to_string(html, "<li value=\"%s\"><a href=\"%s/%s\">",
|
||||||
|
field, struri(conn->uri), field);
|
||||||
|
|
||||||
|
field = line;
|
||||||
|
line = strchr(line, '\t');
|
||||||
|
if (line)
|
||||||
|
*line++ = 0;
|
||||||
|
|
||||||
|
add_header_to_string(html, field);
|
||||||
|
add_to_string(html, "</a> ");
|
||||||
|
|
||||||
|
if (line) {
|
||||||
|
field = line;
|
||||||
|
line = strchr(line, '\t');
|
||||||
|
if (line)
|
||||||
|
*line++ = 0;
|
||||||
|
|
||||||
|
add_header_to_string(html, field);
|
||||||
}
|
}
|
||||||
|
add_to_string(html, "</li>");
|
||||||
add_format_to_string(html, "<dt><a href=\"%s/%s\">%s</a></dt><dd>%s</dd>\n",
|
|
||||||
struri(conn->uri), line, line, desc);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NNTP_TARGET_QUIT:
|
case NNTP_TARGET_QUIT:
|
||||||
|
@ -52,34 +52,35 @@ struct protocol_backend {
|
|||||||
unsigned int need_slash_after_host:1;
|
unsigned int need_slash_after_host:1;
|
||||||
unsigned int free_syntax:1;
|
unsigned int free_syntax:1;
|
||||||
unsigned int need_ssl:1;
|
unsigned int need_ssl:1;
|
||||||
|
unsigned int keep_double_slashes:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct protocol_backend protocol_backends[] = {
|
static const struct protocol_backend protocol_backends[] = {
|
||||||
{ "about", 0, about_protocol_handler, 0, 0, 1, 0 },
|
{ "about", 0, about_protocol_handler, 0, 0, 1, 0, 1 },
|
||||||
{ "bittorrent", 0, bittorrent_protocol_handler, 0, 0, 1, 0 },
|
{ "bittorrent", 0, bittorrent_protocol_handler, 0, 0, 1, 0, 1 },
|
||||||
{ "data", 0, data_protocol_handler, 0, 0, 1, 0 },
|
{ "data", 0, data_protocol_handler, 0, 0, 1, 0, 1 },
|
||||||
{ "file", 0, file_protocol_handler, 1, 0, 0, 0 },
|
{ "file", 0, file_protocol_handler, 1, 0, 0, 0, 0 },
|
||||||
{ "finger", 79, finger_protocol_handler, 1, 1, 0, 0 },
|
{ "finger", 79, finger_protocol_handler, 1, 1, 0, 0, 1 },
|
||||||
{ "fsp", 21, fsp_protocol_handler, 1, 1, 0, 0 },
|
{ "fsp", 21, fsp_protocol_handler, 1, 1, 0, 0, 1 },
|
||||||
{ "ftp", 21, ftp_protocol_handler, 1, 1, 0, 0 },
|
{ "ftp", 21, ftp_protocol_handler, 1, 1, 0, 0, 0 },
|
||||||
{ "gopher", 70, gopher_protocol_handler, 1, 1, 0, 0 },
|
{ "gopher", 70, gopher_protocol_handler, 1, 1, 0, 0, 1 },
|
||||||
{ "http", 80, http_protocol_handler, 1, 1, 0, 0 },
|
{ "http", 80, http_protocol_handler, 1, 1, 0, 0, 1 },
|
||||||
{ "https", 443, https_protocol_handler, 1, 1, 0, 1 },
|
{ "https", 443, https_protocol_handler, 1, 1, 0, 1, 1 },
|
||||||
{ "javascript", 0, NULL, 0, 0, 1, 0 },
|
{ "javascript", 0, NULL, 0, 0, 1, 0, 1 },
|
||||||
{ "news", 0, news_protocol_handler, 0, 0, 1, 0 },
|
{ "news", 0, news_protocol_handler, 0, 0, 1, 0, 1 },
|
||||||
{ "nntp", 119, nntp_protocol_handler, 1, 1, 0, 0 },
|
{ "nntp", 119, nntp_protocol_handler, 1, 1, 0, 0, 0 },
|
||||||
{ "nntps", 563, nntp_protocol_handler, 1, 1, 0, 1 },
|
{ "nntps", 563, nntp_protocol_handler, 1, 1, 0, 1, 0 },
|
||||||
{ "proxy", 3128, proxy_protocol_handler, 1, 1, 0, 0 },
|
{ "proxy", 3128, proxy_protocol_handler, 1, 1, 0, 0, 1 },
|
||||||
{ "smb", 139, smb_protocol_handler, 1, 1, 0, 0 },
|
{ "smb", 139, smb_protocol_handler, 1, 1, 0, 0, 1 },
|
||||||
{ "snews", 0, news_protocol_handler, 0, 0, 1, 0 },
|
{ "snews", 0, news_protocol_handler, 0, 0, 1, 0, 1 },
|
||||||
|
|
||||||
/* Keep these last! */
|
/* Keep these last! */
|
||||||
{ NULL, 0, NULL, 0, 0, 1, 0 },
|
{ NULL, 0, NULL, 0, 0, 1, 0, 1 },
|
||||||
|
|
||||||
{ "user", 0, NULL, 0, 0, 0, 0 },
|
{ "user", 0, NULL, 0, 0, 0, 0, 1 },
|
||||||
/* Internal protocol for mapping to protocol.user.* handlers. Placed
|
/* Internal protocol for mapping to protocol.user.* handlers. Placed
|
||||||
* last because it's checked first and else should be ignored. */
|
* last because it's checked first and else should be ignored. */
|
||||||
{ "custom", 0, NULL, 0, 0, 1, 0 },
|
{ "custom", 0, NULL, 0, 0, 1, 0, 1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -174,6 +175,14 @@ get_protocol_need_slash_after_host(enum protocol protocol)
|
|||||||
return protocol_backends[protocol].need_slash_after_host;
|
return protocol_backends[protocol].need_slash_after_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_protocol_keep_double_slashes(enum protocol protocol)
|
||||||
|
{
|
||||||
|
assert(VALID_PROTOCOL(protocol));
|
||||||
|
if_assert_failed return 0;
|
||||||
|
return protocol_backends[protocol].keep_double_slashes;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
get_protocol_free_syntax(enum protocol protocol)
|
get_protocol_free_syntax(enum protocol protocol)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +44,7 @@ typedef void (protocol_external_handler_T)(struct session *, struct uri *);
|
|||||||
|
|
||||||
int get_protocol_port(enum protocol protocol);
|
int get_protocol_port(enum protocol protocol);
|
||||||
int get_protocol_need_slashes(enum protocol protocol);
|
int get_protocol_need_slashes(enum protocol protocol);
|
||||||
|
int get_protocol_keep_double_slashes(enum protocol protocol);
|
||||||
int get_protocol_need_slash_after_host(enum protocol protocol);
|
int get_protocol_need_slash_after_host(enum protocol protocol);
|
||||||
int get_protocol_free_syntax(enum protocol protocol);
|
int get_protocol_free_syntax(enum protocol protocol);
|
||||||
int get_protocol_need_ssl(enum protocol protocol);
|
int get_protocol_need_ssl(enum protocol protocol);
|
||||||
|
@ -106,7 +106,7 @@ static struct option_info uri_rewrite_options[] = {
|
|||||||
#define INIT_OPT_DUMB_PREFIX(prefix, uri) \
|
#define INIT_OPT_DUMB_PREFIX(prefix, uri) \
|
||||||
INIT_OPT_STRING("protocol.rewrite.dumb", NULL, prefix, 0, uri, NULL)
|
INIT_OPT_STRING("protocol.rewrite.dumb", NULL, prefix, 0, uri, NULL)
|
||||||
|
|
||||||
INIT_OPT_DUMB_PREFIX("elinks", ELINKS_HOMEPAGE),
|
INIT_OPT_DUMB_PREFIX("elinks", ELINKS_WEBSITE_URL),
|
||||||
INIT_OPT_DUMB_PREFIX("documentation", ELINKS_DOC_URL),
|
INIT_OPT_DUMB_PREFIX("documentation", ELINKS_DOC_URL),
|
||||||
INIT_OPT_DUMB_PREFIX("bz", ELINKS_BUGS_URL),
|
INIT_OPT_DUMB_PREFIX("bz", ELINKS_BUGS_URL),
|
||||||
INIT_OPT_DUMB_PREFIX("bug", ELINKS_BUGS_URL),
|
INIT_OPT_DUMB_PREFIX("bug", ELINKS_BUGS_URL),
|
||||||
|
55
src/protocol/test/test-get-translated-uri
Executable file
55
src/protocol/test/test-get-translated-uri
Executable file
@ -0,0 +1,55 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
test_description='Test URI translation'
|
||||||
|
|
||||||
|
. "$TEST_LIB"
|
||||||
|
|
||||||
|
test_uri_translation () {
|
||||||
|
before="$1"; shift
|
||||||
|
cwd="$1"; shift
|
||||||
|
translated="$(uri-test "$before" "$cwd")"
|
||||||
|
cond=""
|
||||||
|
for expected; do
|
||||||
|
cond="${cond:+$cond ||
|
||||||
|
}test \"$translated\" = \"$expected\""
|
||||||
|
done
|
||||||
|
|
||||||
|
test_expect_success "Translate $before in $cwd" "$cond"
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
|
||||||
|
# RFC 1738 section 3.10 says "localhost" and "" as <host> mean
|
||||||
|
# the same thing. So we disregard the spelling in these tests.
|
||||||
|
|
||||||
|
test_uri_translation "/usr/bin/elinks" "/srv/git" \
|
||||||
|
"file://localhost/usr/bin/elinks" \
|
||||||
|
"file:///usr/bin/elinks"
|
||||||
|
|
||||||
|
test_uri_translation "index.html" "/var/www" \
|
||||||
|
"file://localhost/var/www/index.html" \
|
||||||
|
"file:///var/www/index.html"
|
||||||
|
|
||||||
|
test_uri_translation "../" "/usr/share/doc" \
|
||||||
|
"file://localhost/usr/share/" \
|
||||||
|
"file:///usr/share/"
|
||||||
|
|
||||||
|
test_uri_translation "../../lib/libc.so" "/usr/include/rpc" \
|
||||||
|
"file://localhost/usr/lib/libc.so" \
|
||||||
|
"file:///usr/lib/libc.so"
|
||||||
|
|
||||||
|
test_uri_translation "etc/issue" "/" \
|
||||||
|
"file://localhost/etc/issue" \
|
||||||
|
"file:///etc/issue"
|
||||||
|
|
||||||
|
# SUSv2: "A pathname that begins with two successive slashes may be
|
||||||
|
# interpreted in an implementation-defined manner." Domain/OS and
|
||||||
|
# Cygwin are said to do so.
|
||||||
|
test_uri_translation "apollo_logo" "//melchior/sys" \
|
||||||
|
"file://melchior/sys/apollo_logo" \
|
||||||
|
"file://localhost//melchior/sys/apollo_logo" \
|
||||||
|
"file://localhost/%2Fmelchior/sys/apollo_logo" \
|
||||||
|
"file:////melchior/sys/apollo_logo" \
|
||||||
|
"file:///%2Fmelchior/sys/apollo_logo"
|
||||||
|
|
||||||
|
test_done
|
@ -16,6 +16,11 @@ main(int argc, char **argv)
|
|||||||
* taking arguments like --normalize-uri=<arg> etc. */
|
* taking arguments like --normalize-uri=<arg> etc. */
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
fprintf(stdout, "%s\n", normalize_uri(NULL, argv[1]));
|
fprintf(stdout, "%s\n", normalize_uri(NULL, argv[1]));
|
||||||
|
} else if (argc == 3) {
|
||||||
|
struct uri *translated = get_translated_uri(argv[1], argv[2]);
|
||||||
|
if (translated == NULL)
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
fprintf(stdout, "%s\n", struri(translated));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -692,7 +692,7 @@ normalize_uri(struct uri *uri, unsigned char *uristring)
|
|||||||
{
|
{
|
||||||
unsigned char *parse_string = uristring;
|
unsigned char *parse_string = uristring;
|
||||||
unsigned char *src, *dest, *path;
|
unsigned char *src, *dest, *path;
|
||||||
int need_slash = 0;
|
int need_slash = 0, keep_dslash = 1;
|
||||||
int parse = (uri == NULL);
|
int parse = (uri == NULL);
|
||||||
struct uri uri_struct;
|
struct uri uri_struct;
|
||||||
|
|
||||||
@ -720,8 +720,10 @@ normalize_uri(struct uri *uri, unsigned char *uristring)
|
|||||||
if (get_protocol_free_syntax(uri->protocol))
|
if (get_protocol_free_syntax(uri->protocol))
|
||||||
return uristring;
|
return uristring;
|
||||||
|
|
||||||
if (uri->protocol != PROTOCOL_UNKNOWN)
|
if (uri->protocol != PROTOCOL_UNKNOWN) {
|
||||||
need_slash = get_protocol_need_slash_after_host(uri->protocol);
|
need_slash = get_protocol_need_slash_after_host(uri->protocol);
|
||||||
|
keep_dslash = get_protocol_keep_double_slashes(uri->protocol);
|
||||||
|
}
|
||||||
|
|
||||||
path = uri->data - need_slash;
|
path = uri->data - need_slash;
|
||||||
dest = src = path;
|
dest = src = path;
|
||||||
@ -785,8 +787,7 @@ normalize_uri(struct uri *uri, unsigned char *uristring)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (is_uri_dir_sep(uri, src[1]) &&
|
} else if (is_uri_dir_sep(uri, src[1]) && !keep_dslash) {
|
||||||
uri->protocol == PROTOCOL_FILE) {
|
|
||||||
/* // - ignore first '/'. */
|
/* // - ignore first '/'. */
|
||||||
src += 1;
|
src += 1;
|
||||||
continue;
|
continue;
|
||||||
|
@ -4,13 +4,18 @@
|
|||||||
|
|
||||||
#define VERSION_STRING VERSION
|
#define VERSION_STRING VERSION
|
||||||
|
|
||||||
|
#define COPYRIGHT_STRING "(C) 1999 - 2002 Mikulas Patocka\n" \
|
||||||
|
"(C) 2001 - 2004 Petr Baudis\n" \
|
||||||
|
"(C) 2002 - 2007 Jonas Fonseca\n"
|
||||||
|
|
||||||
/* This option will take effect when WWW_HOME environment variable is NOT
|
/* This option will take effect when WWW_HOME environment variable is NOT
|
||||||
* set - you'll go automatically to this URL. If the value is just "",
|
* set - you'll go automatically to this URL. If the value is just "",
|
||||||
* you'll get either goto dialog or empty page, depending on the value of
|
* you'll get either goto dialog or empty page, depending on the value of
|
||||||
* startup_goto_dialog. */
|
* startup_goto_dialog. */
|
||||||
#define WWW_HOME_URL ""
|
#define WWW_HOME_URL ""
|
||||||
|
|
||||||
#define ELINKS_HOMEPAGE "http://elinks.cz/"
|
#define ELINKS_WEBSITE_URL "http://elinks.cz/"
|
||||||
|
#define ELINKS_AUTHORS_URL "http://elinks.cz/authors.html"
|
||||||
#define ELINKS_DOC_URL "http://elinks.cz/documentation/"
|
#define ELINKS_DOC_URL "http://elinks.cz/documentation/"
|
||||||
#define ELINKS_BUGS_URL "http://bugzilla.elinks.cz/"
|
#define ELINKS_BUGS_URL "http://bugzilla.elinks.cz/"
|
||||||
#define ELINKS_GITWEB_URL "http://repo.or.cz/w/elinks.git"
|
#define ELINKS_GITWEB_URL "http://repo.or.cz/w/elinks.git"
|
||||||
|
@ -481,9 +481,12 @@ stat_date(struct string *string, struct stat *stp)
|
|||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
/* comparison function for qsort() */
|
||||||
static int
|
static int
|
||||||
compare_dir_entries(struct directory_entry *d1, struct directory_entry *d2)
|
compare_dir_entries(const void *v1, const void *v2)
|
||||||
{
|
{
|
||||||
|
const struct directory_entry *d1 = v1, *d2 = v2;
|
||||||
|
|
||||||
if (d1->name[0] == '.' && d1->name[1] == '.' && !d1->name[2]) return -1;
|
if (d1->name[0] == '.' && d1->name[1] == '.' && !d1->name[2]) return -1;
|
||||||
if (d2->name[0] == '.' && d2->name[1] == '.' && !d2->name[2]) return 1;
|
if (d2->name[0] == '.' && d2->name[1] == '.' && !d2->name[2]) return 1;
|
||||||
if (d1->attrib[0] == 'd' && d2->attrib[0] != 'd') return -1;
|
if (d1->attrib[0] == 'd' && d2->attrib[0] != 'd') return -1;
|
||||||
@ -580,8 +583,7 @@ get_directory_entries(unsigned char *dirname, int get_hidden)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
qsort(entries, size, sizeof(*entries),
|
qsort(entries, size, sizeof(*entries), compare_dir_entries);
|
||||||
(int (*)(const void *, const void *)) compare_dir_entries);
|
|
||||||
|
|
||||||
memset(&entries[size], 0, sizeof(*entries));
|
memset(&entries[size], 0, sizeof(*entries));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user