google-code-export / digitalus-cms

Automatically exported from code.google.com/p/digitalus-cms
1 stars 1 forks source link

Permissions for hyphen page names don't save properly - 1.10 Alpha 2 #176

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Log into the Admin CP and click the "Pages" tab
2. Add a new page that uses a hyphen in its page name:
 Page Name: My-Page
 Parent page: Site Root
 Template: default/default
 Continue adding pages?: checked
 Show Page on menu?: checked
 Publish page instantly?: checked
 Submit
3. Now navigate to the "Site" tab
4. Open up the "guest (Guest)" group from the left side menu.
5. Now open up the "Public permissions" for this group from the right side menu.
6. Find the checkbox labeled "My-Page" and check it.
7. Then submit the form by clicking "Update Permission"
8. Now navigate back to where you were to see if it saved properly by clicking 
the "Public permissions" link on the right side menu.
9. And surprise the checkbox is NOT checked like it should be!
10. Try opening the "/My-Page" page in your browser outside of the admin cp and 
it will load if you are logged in as the administrator. But if you log out 
firt, you will prompted to log in before being able to see it.

What is the expected output? What do you see instead?
The expected output is that the checkbox is supposed to remain checked if it is 
saving to the database properly, rather the database is stripping the hyphens 
even though the hyphens are supposed to be valid in the page names and the 
permissions aren't found in the database when they are saved since they are 
saved under a different name.

What version of the product are you using? On what operating system?
I'm using the "Digitalus 1.10.0 Alpha2 Release" version.

Please provide any additional information below.
If you open up PHPMyAdmin, and open up the `groups` table, you'll find an entry 
in there representing the "guest" permissions. In my case they read:
a:11:{s:17:"mod_contact_index";s:1:"0";s:17:"mod_forward_index";s:1:"0";s:15:"mo
d_login_index";s:1:"0";s:22:"mod_login_public_index";s:1:"0";s:28:"mod_login_pub
lic_newpassword";s:1:"0";s:29:"mod_login_public_registration";s:1:"0";s:16:"mod_
search_index";s:1:"0";s:6:"mypage";s:1:"1";s:8:"404_page";s:1:"1";s:12:"site_off
line";s:1:"1";s:4:"home";s:1:"1";}

If you toss that to PHP's unserialize function together with a print_r, you'll 
see that it reads:
Array
(
    [mod_contact_index] => 0
    [mod_forward_index] => 0
    [mod_login_index] => 0
    [mod_login_public_index] => 0
    [mod_login_public_newpassword] => 0
    [mod_login_public_registration] => 0
    [mod_search_index] => 0
    [mypage] => 1
    [404_page] => 1
    [site_offline] => 1
    [home] => 1
)

Notice here that the database is saving "My-Page" as "mypage".
Now edit the serialized data and change:
"s:6:"mypage";
To:
s:7:"my-page";

Re-save the entry to the database with the new permissions.
And try loading "/My-Page" in your browser again while logged out to test the 
guest permissions. It should load properly unlike before.

Original issue reported on code.google.com by Ultima...@gmail.com on 29 Dec 2011 at 1:03

GoogleCodeExporter commented 9 years ago
After much searching, I believe this problem is caused by the 
Zend_Form_Element::filterName() which appears to filter form elements' names to 
a very limited charset: [^a-zA-Z0-9_\x7f-\xff]
Notice that this character set does not allow hyphen characters.

Original comment by Ultima...@gmail.com on 29 Dec 2011 at 8:33