SMF Development > Fixed or Bogus Bugs
XML functions broken for PHP 5.3.10
RétroX:
It appears that the cleanXml() function (QueryString.php) is broken under SMF 2.0.2 when using a Unicode encoding. I've found that this code doesn't work on my system:
--- Code: ---preg_replace('~[\x00-\x08\x0B\x0C\x0E-\x19' . ($context['utf8'] ? (@version_compare(PHP_VERSION, '4.3.3') != -1 ? '\x{D800}-\x{DFFF}\x{FFFE}\x{FFFF}' : "\xED\xA0\x80-\xED\xBF\xBF\xEF\xBF\xBE\xEF\xBF\xBF") : '') . ']~' . ($context['utf8'] ? 'u' : ''), '', $string)
--- End code ---
And returns the following error:
--- Code: ---Warning: preg_replace(): Compilation failed: disallowed Unicode code point (>= 0xd800 && <= 0xdfff) at offset 34
--- End code ---
I'm using an Arch Linux system locally, which is why I have such a bleeding-edge PHP version. On most servers, you won't find a version of PHP that's this up-to-date, but it's still a very big issue.
I've tried taking the code out of SMF and it does appear to work when $context['utf8'] == false, however, I'm assuming that this still isn't the intended behaviour.
Is this just an error in the setup on my system, or is this an error in SMF? I don't think that forcing $context['utf8'] to be false within this function would be a good idea, because quite honestly, I don't know what it does.
Essentially, this error breaks all of the XML functions of the forum, such as quick edit, quoting, auto-suggest, etc.
Spuds:
Well that stinks ! ... looks like its a change in the PCRE engine starting at rev 8.3, where it will toss that warning if you specify the surrogate range D800–DFFF. These are not technically characters, and are invalid in UTF-8 (strict) ... which is why they were stripped ... so looks like preg now complains :-X
High Surrogates (D800–DB7F)
High Private Use Surrogates (DB80–DBFF)
Low Surrogates (DC00–DFFF)
Do the following replace and see if it fixes the problem on your setup, I don't have a setup to test it on ATM.
--- Code: (find) ---preg_replace('~[\x00-\x08\x0B\x0C\x0E-\x19' . ($context['utf8'] ? (@version_compare(PHP_VERSION, '4.3.3') != -1 ? '\x{D800}-\x{DFFF}\x{FFFE}\x{FFFF}' : "\xED\xA0\x80-\xED\xBF\xBF\xEF\xBF\xBE\xEF\xBF\xBF") : '') . ']~' . ($context['utf8'] ? 'u' : ''), '', $string)
--- End code ---
--- Code: (replace) ---return preg_replace('~[\x00-\x08\x0B\x0C\x0E-\x19' . ($context['utf8'] ? '\x{FFFE}\x{FFFF}' : '') . ']~' . ($context['utf8'] ? 'u' : ''), '', $string);
--- End code ---
RétroX:
Four days late, but yes, that works. :)
reklipz:
I'm having this same/similar issue. When clicking "Insert Quote" while forming a reply, this error is generated and nothing seems to happen.
--- Quote ---FreeBSD c16 8.2-RELEASE-p5 FreeBSD 8.2-RELEASE-p5 #13: Thu Dec 29 10:33:00 UTC 2011 root@x3:/usr/obj/usr/src/sys/NFSN32 i386
--- End quote ---
How do I go about applying your fix to this specific case? I'm familiar with PHP, etc., but the information in the post isn't leaving me with a clear picture of how to apply it for some reason...
:-[ -- I totally skipped the first line of the original post. I think I've got it now, :).
So, this is a system specific fix. How long until we receive an officially supported fix?
Spuds:
Welcome to SMF
It looks to be more of a specific PCRE library issue than a specific system issue ... if php is compiled using the latest external version of the PCRE library it looks to cause this warning error.
It will be fixed in SMF 2.1, I'm not sure if there will be a maintenance release (2.0.3) before then or if this fix would make it in to that TBH.
If your looking for timelines, well you came to the wrong place :P ... things happen as they can around here, never sooner. We are just happy that people are willing to volunteer their time to do all this for free :)
Navigation
[0] Message Index
[#] Next page
Go to full version