From 89573793193b82b9e1a979bf93f582643570d3bb Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Wed, 11 Oct 2006 16:50:49 +0000 Subject: [PATCH 1/7] tree_dup: call object_nolock on the cloned children of the new tree --- src/config/opttypes.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/config/opttypes.c b/src/config/opttypes.c index 4a565393..5f49ebb3 100644 --- a/src/config/opttypes.c +++ b/src/config/opttypes.c @@ -383,6 +383,7 @@ tree_dup(struct option *opt, struct option *template) struct option *new_opt = copy_option(option); if (!new_opt) continue; + object_nolock(new_opt, "option"); add_to_list_end(*new, new_opt); new_opt->root = opt; From 5605a046a7c135ed1aaf6d070270e03c2b36c08c Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Fri, 13 Oct 2006 09:02:04 +0000 Subject: [PATCH 2/7] handle_interlink_event: don't check whether key <= 0xFF This is a given, because any value >= 0x100 is negated. --- src/terminal/event.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/terminal/event.c b/src/terminal/event.c index 9d591016..adbd2195 100644 --- a/src/terminal/event.c +++ b/src/terminal/event.c @@ -360,14 +360,16 @@ handle_interlink_event(struct terminal *term, struct interlink_event *ilev) } } - if (key < 0x80 || key > 0xFF || !utf8_io) { + /* Note: We know that key <= 0xFF. */ + + if (key < 0x80 || !utf8_io) { /* This byte is not part of a multibyte character * encoding: either it is outside of the ranges for * UTF-8 start and continuation bytes or UTF-8 I/O mode * is disabled. */ #ifdef CONFIG_UTF8 - if (key >= 0 && key <= 0xFF && !utf8_io) { + if (key >= 0 && !utf8_io) { /* Not special and UTF-8 mode is disabled: * recode from the terminal charset to UCS-4. */ From 28261fcfba327bb3ec060bfbfb77741bd99f135f Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Fri, 13 Oct 2006 09:00:54 +0000 Subject: [PATCH 3/7] check_dialog: compare return value from widget handlers explicitly Explicitly compare the value that is returned by the widget handler against EVENT_NOT_PROCESSED rather than relying on the fact that EVENT_NOT_PROCESSED is equal to 1. ffeedbdc5045a6a5db2bc75ecaab56bfe46c80ea --- src/bfu/dialog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bfu/dialog.c b/src/bfu/dialog.c index 34e60266..7795dd15 100644 --- a/src/bfu/dialog.c +++ b/src/bfu/dialog.c @@ -474,7 +474,8 @@ check_dialog(struct dialog_data *dlg_data) continue; if (widget_data->widget->handler && - widget_data->widget->handler(dlg_data, widget_data)) { + widget_data->widget->handler(dlg_data, widget_data) + == EVENT_NOT_PROCESSED) { select_widget(dlg_data, widget_data); redraw_dialog(dlg_data, 0); return 1; From 3041ef5ff1fbff04e430ff31126aef4ebd11839d Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Sun, 15 Oct 2006 21:33:56 +0000 Subject: [PATCH 4/7] Use foreachbacksafe in shrink_format_cache I hope that it isn't too confusing to re-use the local variable next with foreachbacksafe. --- src/document/document.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/document/document.c b/src/document/document.c index 9765197a..5a39574c 100644 --- a/src/document/document.c +++ b/src/document/document.c @@ -285,7 +285,7 @@ shrink_format_cache(int whole) assertm(format_cache_entries >= 0, "format_cache_entries underflow on entry"); if_assert_failed format_cache_entries = 0; - foreachback (document, format_cache) { + foreachbacksafe (document, next, format_cache) { if (is_object_used(document)) continue; /* If we are not purging the whole format cache, stop @@ -293,10 +293,7 @@ shrink_format_cache(int whole) if (!whole && format_cache_entries <= format_cache_size) break; - /* Jump back to already processed entry (or list head), and let - * the foreachback move it to the next entry to go. */ - document = document->next; - done_document(document->prev); + done_document(document); format_cache_entries--; } From f7fba1b8e4468116c6f99bdff3aae16f43518da9 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Sun, 15 Oct 2006 21:43:42 +0000 Subject: [PATCH 5/7] Use DNS_ERROR instead of -1 where appropriate --- src/network/dns.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/network/dns.c b/src/network/dns.c index 62fb0636..0d0622b7 100644 --- a/src/network/dns.c +++ b/src/network/dns.c @@ -159,7 +159,7 @@ do_real_lookup(unsigned char *name, struct sockaddr_storage **addrs, int *addrno memset(&hint, 0, sizeof(hint)); hint.ai_family = AF_UNSPEC; hint.ai_socktype = SOCK_STREAM; - if (getaddrinfo(name, NULL, &hint, &ai) != 0) return -1; + if (getaddrinfo(name, NULL, &hint, &ai) != 0) return DNS_ERROR; #else /* Seems there are problems on Mac, so we first need to try @@ -386,7 +386,7 @@ do_queued_lookup(struct dnsquery *query) assertm(!dns_queue->next_in_queue, "DNS queue corrupted"); dns_queue->next_in_queue = query; dns_queue = query; - return -1; + return DNS_ERROR; } dns_queue = query; @@ -512,7 +512,7 @@ kill_dns_request(void **queryref) assert(query); query->done = NULL; - done_dns_lookup(query, -1); + done_dns_lookup(query, DNS_ERROR); } void From f22dbfb6f59aa2bbd289d93834dfdc0a27870b4f Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Fri, 20 Oct 2006 21:04:52 +0000 Subject: [PATCH 6/7] SMJS: block_pr0n: return the original URI if not blocking it Return the original URI instead of the value true, so that any later hooks will have the URI. --- contrib/smjs/hooks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/smjs/hooks.js b/contrib/smjs/hooks.js index 55fa1ae8..7973640a 100644 --- a/contrib/smjs/hooks.js +++ b/contrib/smjs/hooks.js @@ -74,7 +74,7 @@ function block_pr0n(uri) { return ""; } - return true; + return uri; } elinks.follow_url_hooks.push(block_pr0n); From c884123d5373c885c02ab342de7e689257d45945 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Fri, 20 Oct 2006 23:11:25 +0000 Subject: [PATCH 7/7] SMJS: Add scripts for YouTube and PornoTube --- contrib/smjs/pornotube.js | 30 ++++++++++++++++++++++++++++++ contrib/smjs/youtube.js | 27 +++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 contrib/smjs/pornotube.js create mode 100644 contrib/smjs/youtube.js diff --git a/contrib/smjs/pornotube.js b/contrib/smjs/pornotube.js new file mode 100644 index 00000000..b3e50913 --- /dev/null +++ b/contrib/smjs/pornotube.js @@ -0,0 +1,30 @@ +/* Play videos at pornotube.com with minimal niggling. Just follow the link + * from the front page or the search page, and the video will automatically + * be loaded. */ + +function pornotube_callback(cached) { + var user_re = /\(\d+)\<\/user_id\>/; + var media_re = /\(\d+)\<\/media_id\>/; + + var user = cached.content.match(user_re)[1]; + var media = cached.content.match(media_re)[1]; + + var uri = "http://video.pornotube.com/" + user + "/" + media + ".flv"; + + elinks.location = uri; +} + +function load_pornotube(cached, vs) { + if (!cached.uri.match(/^http:\/\/(?:www\.)?pornotube\.com\/media\.php/)) + return true; + + var re = /SWFObject\("player\/v\.swf\?v=(.*?)"/; + var hash = cached.content.match(re)[1]; + + var uri = "http://www.pornotube.com/player/player.php?" + hash; + + elinks.load_uri(uri, pornotube_callback); + + return true; +} +elinks.preformat_html_hooks.push(load_pornotube); diff --git a/contrib/smjs/youtube.js b/contrib/smjs/youtube.js new file mode 100644 index 00000000..c81db88d --- /dev/null +++ b/contrib/smjs/youtube.js @@ -0,0 +1,27 @@ +/* Play videos at YouTube with minimal niggling. Just load the page for a video, + * and the video will automatically be loaded. */ +function load_youtube(cached, vs) { + if (!cached.uri.match(/http:\/\/(?:www\.)?youtube\.com\/(?:watch(?:\.php)?)?\?v=(?:[^&]+).*/)) + return true; + + var params_match = cached.content.match(/player2\.swf\?([^"]+)"/); + if (!params_match) return true; + + var url = 'http://www.youtube.com/get_video?' + params_match[1]; + var meta = ''; + + cached.content = cached.content.replace(//, "" + meta); + + return true; +} +elinks.preformat_html_hooks.push(load_youtube); + +/* When one tries to follow a link to , + * redirect to , which has the information + * that is necessary to get the actual video file. */ +function redirect_embedded_youtube(uri) { + var uri_match = uri.match(/http:\/\/(?:www\.)?youtube\.com\/v\/([^&]+).*/); + if (!uri_match) return true; + return 'http://www.youtube.com/watch?v=' + uri_match[1]; +} +elinks.follow_url_hooks.push(redirect_embedded_youtube);