note 85921 added to function.quoted-printable-decode

From: Date: Wed, 24 Sep 2008 18:16:09 +0000
Subject: note 85921 added to function.quoted-printable-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-144680@lists.php.net to get a copy of this message
In response to Bobo, using: chunk_split($string, 76, "=\n"); Can result to broken encoding (in some rare cases). This is for a couple of reasons. Firstly, the chunk split could insert a newline between an encoding if it was on the end of a line. So it could turn an entity: =20 in to =2=\n0 - which breaks it. Secondly, the spec says that the line should be no longer than 76 in total, which includes the '=' used to indicate a soft newline. Additionally, there's a couple of minor readability issues with it. Firstly, chunk_split leaves a trailing newline - which is unnecessary. Lastly, it does not consider newlines already in the text (which breaks readability) so it often wraps when not needed. Here's a snippet which will fix all the issues mentioned: preg_replace('/[^\r\n]{73}[^=\r\n]{2}/', "$0=\r\n", $data); ---- Server IP: 92.48.74.199 Probable Submitter: 81.140.40.33 ---- Manual Page -- http://www.php.net/manual/en/function.quoted-printable-decode.php Edit -- https://master.php.net/note/edit/85921 Del: integrated -- https://master.php.net/note/delete/85921/integrated Del: useless -- https://master.php.net/note/delete/85921/useless Del: bad code -- https://master.php.net/note/delete/85921/bad+code Del: spam -- https://master.php.net/note/delete/85921/spam Del: non-english -- https://master.php.net/note/delete/85921/non-english Del: in docs -- https://master.php.net/note/delete/85921/in+docs Del: other reasons-- https://master.php.net/note/delete/85921 Reject -- https://master.php.net/note/reject/85921 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#144680) next »