zendframework / zf1

This project reached its end-of-life on 2016-09-28. Contains conversion of ZF1 subversion repo to git, from version 15234 forward, and only containing master and release-1.12 branches and 1.12 tags.
https://framework.zend.com/blog/2016-06-28-zf1-eol.html
BSD 3-Clause "New" or "Revised" License
357 stars 800 forks source link

Possible multibyte issue in ActiveMQ driver? #391

Open chriskl opened 10 years ago

chriskl commented 10 years ago

I was just reviewing the API and code for using ActiveMQ from ZF and I saw this line in the Activemq Queue adapter:

$frame->setHeader('content-length', strlen($message));

We intend to send utf-8 messages. Surely the strlen calculation here must instead by a careful 8-bit byte count. According to the spec, this must be bytes, not characters.

We have setup PHP to replace all strlen calls with calls to mb_strlen

chriskl commented 10 years ago

Actually, strlen is used all through the Queue code.

croensch commented 10 years ago

Plain strlen() just counts bytes, the header must be bytes.

We have setup PHP to replace all strlen calls with calls to mb_strlen

IMHO the wrong way to approach the problem.

froschdesign commented 9 years ago

@chriskl, @croensch Any ideas to solve the problem?

croensch commented 9 years ago

I'v used mb_strlen($utf8string, '8bit') before, which takes the string regardless of encoding and counts every 8 bits (so a byte).