From 5af21a8d29e1eb5995ba7fd6ed4f6a2a966ac452 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Fri, 3 Nov 2006 19:22:58 +0100 Subject: [PATCH] Fix perl pre_format_html hook wrt. binary files When trying to view a binary file, this hook would cut it at the first '\0'. --- src/scripting/perl/hooks.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/scripting/perl/hooks.c b/src/scripting/perl/hooks.c index 608c0b70..9a833124 100644 --- a/src/scripting/perl/hooks.c +++ b/src/scripting/perl/hooks.c @@ -135,13 +135,13 @@ do_script_hook_pre_format_html(unsigned char *url, struct cache_entry *cached, if (SvTRUE(ERRSV)) count = 0; /* FIXME: error message ? */ SPAGAIN; if (count == 1) { - unsigned char *new_html = POPpx; + SV *new_html_sv = POPs; + int new_html_len; + unsigned char *new_html = SvPV(new_html_sv, new_html_len); if (new_html) { - int len = strlen(new_html); - - add_fragment(cached, 0, new_html, len); - normalize_cache_entry(cached, len); + add_fragment(cached, 0, new_html, new_html_len); + normalize_cache_entry(cached, new_html_len); } }