wolfcms/wolfcms — pull request #477 by marekmurawski (2013-02-14 10:59:46+00:00)
Title: Page edit fixes - csrf upon error / slug validation / PHP notice

This pull request resolves 3 issues:

#### Slug validation bug

Slug validation bug - slug wasn't actually checked due to **if** statement parentheses/logic error. In fact **every slug** could be set by user - including slugs with **slash, backslash, diacritics** etc. This potentially leaded to page not found and other issues.

Now slug field is properly validated using `Validate::slug()`, so only allowed chars in slug are `[_a-z0-9-]`

#### CSRF upon errors

If user entered invalid value which generated `Flash` error, the CSRF token used for regenerated View was set with **invalid path** so user additionally got **"Invalid CSRF token found"** message.

This forced user to load clean (non-POST) version of page and start all edits again.

Fixed CSRF for View to reflect the same path as POSTing page **(page/edit/# or page/add)**

#### PHP notice under page parts upon input error

Similar to above - if user entered some invalid values and got error message, the View couldn't find **$page->updated_by_name** thus generating **PHP notice**.

![wolf-php-edit-page-notice](https://f.cloud.github.com/assets/546078/156405/74f1c30e-7695-11e2-93ab-ae1c4e8ccbf0.jpg)

Modified controller to set empty value of $page->updated_by_name to avoid notice if this variable wasn't present in $_POST, adittionally modified `views/page/edit.php` to pass `updated_by_name` in hidden input field.