diff --git a/src/scripting/python/hooks.c b/src/scripting/python/hooks.c index 88b97f771..53427f5d9 100644 --- a/src/scripting/python/hooks.c +++ b/src/scripting/python/hooks.c @@ -107,8 +107,9 @@ do_script_hook_pre_format_html(unsigned char *url, struct cache_entry *cached, PyObject *pFunc = PyDict_GetItemString(pDict, "pre_format_html_hook"); if (pFunc && PyCallable_Check(pFunc)) { - PyObject *pValue = PyObject_CallFunction(pFunc, "ss", url, - fragment->data); + PyObject *pValue = PyObject_CallFunction(pFunc, "ss#", url, + fragment->data, + fragment->length); if (pValue && (pValue != Py_None)) { const unsigned char *str = PyString_AsString(pValue); diff --git a/src/scripting/ruby/hooks.c b/src/scripting/ruby/hooks.c index e97016781..df568a9bf 100644 --- a/src/scripting/ruby/hooks.c +++ b/src/scripting/ruby/hooks.c @@ -160,7 +160,7 @@ script_hook_pre_format_html(va_list ap, void *data) 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) { diff --git a/src/scripting/see/hooks.c b/src/scripting/see/hooks.c index db629ada9..ed7fc4e5b 100644 --- a/src/scripting/see/hooks.c +++ b/src/scripting/see/hooks.c @@ -171,7 +171,8 @@ script_hook_pre_format_html(va_list ap, void *data) return EVENT_HOOK_STATUS_NEXT; SEE_SET_STRING(args[0], SEE_string_sprintf(see, "%s", url)); - SEE_SET_STRING(args[1], SEE_string_sprintf(see, "%s", fragment->data)); + SEE_SET_STRING(args[1], SEE_string_sprintf(see, "%.*s", fragment->data, + fragment->length)); if (!call_see_hook(see, ses, "pre_format_html", args, sizeof_array(args), &result)) return EVENT_HOOK_STATUS_NEXT;