"No page selected" after saving from editor

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

"No page selected" after saving from editor

Post by cmb » Thu Jun 14, 2012 6:39 pm

Hello Developers,

if the page heading contains more than one whitespace in a row, after saving the page will not be found. This is caused by the latest change to rfc(), which reduces all consecutive whitespace to a single space (for cleaner URLs). I suggest to change cmsimple/adm.php line 458:

Code: Select all

array_splice($temp, -1, 1, uenc(preg_replace('/\s+/isu', ' ', trim(strip_tags($matches[1]))))); 
But I found another issue: it does still not work, when a space is entered at the end of the heading. tinyMCE converts this to a UTF-8 non-breaking space, and this is not stripped of by trim()!

But even worse: in cmsimple/cms.php line 595 the UTF-8 non-breaking space is being partially replaced by a space (\xC2\xA0 -> \xC2\20) resulting in an invalid UTF-8 byte sequence. It seems that browsers do ignore the \xC2, but of course it's a bug (I've introduced it :oops:) to replace a single byte with the upmost bit set in any UTF-8 string. BTW: the same happens with the former version (/\s+/isu), at least if no specific locale is set. So the regex has to be replaced with a more elaborate one (perhaps even regarding other Unicode whitespace characters). Or should mb_ereg() be preferred? :?

PHP and UTF-8 :cry:

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1660
Joined: Wed Dec 17, 2008 5:08 pm

Re: "No page selected" after saving from editor

Post by svasti » Thu Jun 14, 2012 7:27 pm

Lot's of reasons to bring out a 1.5.4 before introducing new features.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: "No page selected" after saving from editor

Post by cmb » Tue Aug 07, 2012 12:36 pm

I've found out, that a similar stripping of whitespace occurs twice in plugins/pluginloader/page_data/page_data_router.php (line 174 and 216 in r247). So I implemented a small function xh_rmws(), which replaces all (consecutive) unicode whitespace characters by a single space. To additionally trim all unicode whitespace from the beginning and end of a string, it has to be called this way:

Code: Select all

trim(xh_rmws($str)) 
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply