1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-01 03:36:26 -04:00

Fix crashes and problems with rerendering when preformatting with Ruby

This reverts baf7b0e91d:

	Fix segfaults caused by ruby scripting (gentoo bug #121247).

which reverted 5145ae266a:

	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:
Thomas Adam 2006-12-04 23:45:40 +01:00 committed by Jonas Fonseca
parent 1951009a2d
commit d90702aeca

View File

@ -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) {