phacility / xhprof

XHProf is a function-level hierarchical profiler for PHP and has a simple HTML based user interface.
http://pecl.php.net/package/xhprof
Apache License 2.0
2.6k stars 925 forks source link

Wrong value of Content-Length when mbstring.func_overload is enabled #84

Open n0guest opened 8 years ago

n0guest commented 8 years ago

Hi.

I've found a small bug when mbstring.func_overload=2. In parameters of xhprof_generate_mime_header function you're passing length as return of strlen($content). For example here https://github.com/phacility/xhprof/blob/master/xhprof_lib/utils/callgraph_utils.php#L484.

And return value of strlen($content) will differ (from real size of string in bytes) if mbstring.func_overload=2 and mbstring.internal_encoding='utf-8'. Such combination will cause "wrong" length and will cut off part of callgraph image. In result callgraph image will be downloaded only partially and only part of image will be shown in browser (checked in Google Chrome).

I'm not sure about "right way" to fix it, but in my example it can be easily fixed via replacing call of strlen($content) with call of mb_strlen($content, '8bit').