[Melbourne-pm] Handling line ending characters

Stephen Edmonds stephen.edmonds at monash.edu
Thu Nov 1 19:59:09 PDT 2012


I was wondering what techniques people use to handle getting different line
ending characters from various sources.

The specific example I have in mind is a field on a web form. The field
uses jQuery to check client side that the input is less than 100
characters, and then we check again on the server side in perl.  If the
form is submitted from Windows, then you get two characters per line
ending. jQuery converts these to a single character it may think that the
text is ok at 99 characters, but the two characters per line ending are
actually submitted, so our server side check may think it is (for eg) 103
characters and error.

It is an edge case where client side validation doesn't match the server
side validation.

One common solution seems to be to go to a regex with \r?\n, \015?\012,
etc, while another option is to use  Encode::Newlines (which does do
regexes internally, but maintaining that is not our concern)

A further question is do we convert the line endings for the validation and
still store the originally submitted text, or do we store a converted
version?

How do people handle this?

Thanks,
Stephen

-- 
Stephen Edmonds
Technical Lead Applications
Production manager for my.monash, Blackboard and Google Apps
eSolutions, Monash University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20121102/e5f2592d/attachment.html>


More information about the Melbourne-pm mailing list