Hi,
We found an issue where the preg_match was working on our php-5.5 server, but not on our php 5.3 server. This meant that in the function _ckeditor_filter_styles_regex_builder() there would be no matches for preg_match and so the last line $e->removeAttribute('style') would be called and would strip out all the styles.
Pretty much by trial and error we found it to be an issue with the "?" in the regex. Escaping all but one of the question marks seems to fix the problem in php-5.3 and php-5.5 still seems to work with the escaping.
Index: ckeditor_filter.module
===================================================================
--- ckeditor_filter.module (revision 269)
+++ ckeditor_filter.module (working copy)
@@ -76,13 +76,13 @@
*/
function _ckeditor_filter_styles_regex_builder($styles) {
if(!empty($styles)) {
- $regex = '/(?:';
+ $regex = '/(\?:';
foreach($styles as $style) {
- $regex .= '(?!(?:|[^$]*[;\s])' . $style . '\s*:[^$;]*)';
+ $regex .= '(\?!(\?:|[^$]*[;\s])' . $style . '\s*:[^$;]*)';
}
$regex .= '[^$]*$|';
foreach($styles as $style) {
- $regex .= '(?=(?:|[^$]*[;\s])(' . $style . '\s*:[^$;]*))?';
+ $regex .= '(\?=(\?:|[^$]*[;\s])(' . $style . '\s*:[^$;]*))?';
}
return $regex . '[^$]*$)/i';
}
I am couldn't find anything in the change notes for PHP as to why the unescaped regex works on php-5.5 and not php-5.3, but thought this might be useful for anyone running a Centos / RHEL 6 installation with php 5.3
Comments
Comment #2
aschmoe commentedHi hevmills,
This ? escaping definitely fails on php5.6, and I'm confused why this would ever work (not saying you're wrong, just baffled). Should I make a note of this functionality you think in the README or add a known issue?
Sorry about the slow response!
Alex
Comment #4
aschmoe commentedAdded link to this issue from README, closing.
Comment #5
medieval111 commentedThis helped me, also fixes #2447559: Warning: preg_match(): Compilation failed so perhaps someone should look at this?