mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
Fix crashes and problems with rerendering when preformatting with Ruby
This reverts baf7b0e91da55376968e99f42bf62f7091a2a4b4: Fix segfaults caused by ruby scripting (gentoo bug #121247). which reverted 5145ae266a1a541fc26df046af65f7800c6e9b91: Change the Python, Ruby, and SEE hooks for pre-format-html to work properly now that they are given a non-NUL-terminated string. and also makes the Ruby hooks interface generally use rb_str_new(str, len) in favor of rb_str_new2(str) to avoid relying on NUL-terminated being handled correctly by Ruby. Also, it was wrong for the preformat hook which is not always handed a NUL-terminated string. Finally, the gentoo bug (http://bugs.gentoo.org/show_bug.cgi?id=121247) is currently reopened which suggests that the previous fix was not correct.
This commit is contained in:
parent
1951009a2d
commit
d90702aeca
@ -64,12 +64,12 @@ script_hook_goto_url(va_list ap, void *data)
|
||||
if (*url == NULL)
|
||||
return EVENT_HOOK_STATUS_NEXT;
|
||||
|
||||
args[0] = rb_str_new2(*url);
|
||||
args[0] = rb_str_new(*url, strlen(*url));
|
||||
|
||||
if (!ses || !have_location(ses)) {
|
||||
args[1] = Qnil;
|
||||
} else {
|
||||
args[1] = rb_str_new2(struri(cur_loc(ses)->vs.uri));
|
||||
args[1] = rb_str_new(struri(cur_loc(ses)->vs.uri), strlen(struri(cur_loc(ses)->vs.uri)));
|
||||
}
|
||||
|
||||
result = erb_protected_method_call("goto_url_hook", 2, args, &error);
|
||||
@ -113,7 +113,7 @@ script_hook_follow_url(va_list ap, void *data)
|
||||
if (*url == NULL)
|
||||
return EVENT_HOOK_STATUS_NEXT;
|
||||
|
||||
args[0] = rb_str_new2(*url);
|
||||
args[0] = rb_str_new(*url, strlen(*url));
|
||||
|
||||
result = erb_protected_method_call("follow_url_hook", 1, args, &error);
|
||||
if (error) {
|
||||
@ -159,8 +159,7 @@ script_hook_pre_format_html(va_list ap, void *data)
|
||||
return EVENT_HOOK_STATUS_NEXT;
|
||||
|
||||
args[0] = rb_str_new2(url);
|
||||
/* FIXME: Use html_len */
|
||||
args[1] = rb_str_new2(fragment->data);
|
||||
args[1] = rb_str_new(fragment->data, fragment->length);
|
||||
|
||||
result = erb_protected_method_call("pre_format_html_hook", 2, args, &error);
|
||||
if (error) {
|
||||
@ -204,7 +203,7 @@ script_hook_get_proxy(va_list ap, void *data)
|
||||
if (!new_proxy_url || !url)
|
||||
return EVENT_HOOK_STATUS_NEXT;
|
||||
|
||||
args[0] = rb_str_new2(url);
|
||||
args[0] = rb_str_new(url, strlen(url));
|
||||
|
||||
result = erb_protected_method_call("proxy_hook", 1, args, &error);
|
||||
if (error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user