[Melbourne-pm] Handling line ending characters
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
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
How do people handle this?
Technical Lead Applications
Production manager for my.monash, Blackboard and Google Apps
eSolutions, Monash University
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Melbourne-pm