[Catalyst] Validation of entered content

Peter Edwards peter at dragonstaff.co.uk
Mon Apr 11 15:25:10 GMT 2011


>
> On Mon, Apr 11, 2011 at 5:28 AM, John M. Dlugosz <wxju46gefd at snkmail.com>=
wrote:
>
>> I have a form where an admin can change a part of the content on a page.
>>  The form lets someone do it without having to update the files on the
>> server in a more traditional manner; BUT, it must be correct XHTML.  If =
the
>> admin types a <p> or a stray '<' for that matter, it will render the
>> resulting page not well-formed.
>>
>> Combine that with the feature of serving XHTML to browsers that accept i=
t,
>> and the site breaks on browsers other than IE.
>>
>> On 11 April 2011 15:33, Nicholas Wehr <catalyst at bionikchickens.com>
 wrote:

> I've used this before - perhaps it will work for you:
>
>> http://ckeditor.com/
>>
>
>
There are two main JS editors, the one above and TinyMCE, you have to be
careful though.

1) People paste a Word document paragraph in as HTML and it becomes invalid.
Try offering a paste-from-word button to bring up a box they paste into,
then send that to the backend to be run through
http://search.cpan.org/perldoc?Text::Demoroniser before you add it to the
content area.

2) Hitting bugs in these editors giving you invalid XHTML.
What you can do is
- validate by sending the content server-side before save and check with a
DTD schema validator like http://htmlhelp.com/tools/validator/ and on
failure disallow save with a popup warning
- then offer an option to correct invalid XHTML where you send the content
to the backend, run it through htmltidy, then bring it back to the content
area; see the HTML -> XHTML docs in
http://tidy.sourceforge.net/docs/tidy_man.html


Regards, Peter
http://perl.dragonstaff.co.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110411/1a06d=
b62/attachment.htm


More information about the Catalyst mailing list