slackbuilds_ponce/network/elinks/patches/0005-gopher_newlines_tabs_entity.patch

57 lines
1.6 KiB
Diff
Raw Normal View History

#####################################################################
# Fix line feeds without carriage returns.
# Make sure that only lines with tabs are treated as links.
# Support links that don't begin with a '/'.
# dave@slackbuilds.org
#####################################################################
diff -Naur -x .git bb/src/protocol/gopher/gopher.c cc/src/protocol/gopher/gopher.c
--- bb/src/protocol/gopher/gopher.c 2020-01-14 03:19:39.956296190 +0000
+++ cc/src/protocol/gopher/gopher.c 2020-01-14 03:20:05.295045232 +0000
@@ -290,7 +290,7 @@
/* Get entity type, and selector string. */
/* Pick up gopher_entity */
- if (selectorlen > 1 && selector[1] == '/') {
+ if (selectorlen > 1) {
entity = *selector++;
selectorlen--;
}
@@ -333,6 +333,18 @@
}
}
+ if (entity_info->type == '1') {
+ if (strchr(selector, '1') == (char *) selector) {
+ selector++;
+ selectorlen--;
+ }
+ else {
+ if ((char *) selector == "/1") {
+ selectorlen--;
+ }
+ }
+ }
+
state = add_gopher_command(conn, &command, entity, selector, selectorlen);
if (!is_in_state(state, S_CONN))
return state;
@@ -570,7 +582,8 @@
} else if (address.length > 0
&& strlcmp(address.source, address.length - 1,
- "gopher://error.host:1/", -1)) {
+ "gopher://error.host:1/", -1)
+ && selector) {
add_gopher_link(buffer, name, address.source);
} else {
@@ -590,7 +603,7 @@
get_gopher_line_end(unsigned char *data, int datalen)
{
for (; datalen > 1; data++, datalen--)
- if (data[0] == ASCII_CR && data[1] == ASCII_LF)
+ if (data[0] == ASCII_CR || data[0] == ASCII_LF)
return data + 2;
return NULL;