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); 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); 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; 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; 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--; } 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 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. */