Repository navigation
Conversation
snoopdave
left a comment
There was a problem hiding this comment.
LGTM. Might want to add something to CHANGES.md about it
| minlength: 3, | ||
| maxlength: 255, | ||
| email: true, | ||
| regex: /^\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i |
There was a problem hiding this comment.
This regex was here before, but since it's moving: [A-Z]{2,4} rejects valid addresses with longer TLDs, such as user@example.museum, user@studio.photography or user@company.online, so those users can't create a weblog. Its maxlength of 255 also doesn't match the field's maxlength of 50. jQuery Validate's email: true already validates the format, so dropping the regex rule (or allowing TLDs of 2-63 characters) would fix it.
There was a problem hiding this comment.
As a test I updated the regex from roller.js validateEmail
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
It works but now gets rejected up stream.
So I guess it never worked. For simplicity just drop the client validation, and fix up steam.
But its a struts issue
`
<field name="bean.emailAddress">
<field-validator type="email">
<message key="CreateWeblog.error.emailAddressBad">unspecified key</message>
</field-validator>
</field>
There was a problem hiding this comment.
Thanks for testing that. Good find that the server-side validator is the one rejecting long TLDs. I looked at the Struts 7.3.0 jar Roller ships: EmailValidator sets its pattern to end in ([a-z]{2,6}), so anything longer than six letters fails there. Dropping the client regex makes sense to me, as long as the server check stays. EmailValidator extends RegexFieldValidator, so a <param name="regex"> on the field-validator should let Roller use a looser pattern without waiting on Struts. I haven't tried that. Fine as a follow-up.
There was a problem hiding this comment.
One more data point for this: roller.js already has a validateEmail() helper (around line 211) that Register.jsp, Profile.jsp and UserEdit.jsp use, and it accepts long TLDs. So today someone can register as jane@studio.photography and then fail this check when creating a weblog. If the regex rule goes, email: true with minlength covers the same ground and keeps the two forms consistent.
mraible
left a comment
There was a problem hiding this comment.
Thanks, Greg. Moving this into CreateWeblog.jsp fixes the errors on weblog pages that load roller.js, and it's the only page that uses these classes, so this looks right to me. A few small things inline.
This targets roller-6.1.x, but master still has the same block in roller.js (around lines 244-258), so it'll need a forward-port to master too.
| jQuery("form.validate-form").validate(); |
There was a problem hiding this comment.
Nit: these two lines have a tab and trailing whitespace, while the rest of the script uses 4-space indentation.
| jQuery("form.validate-form").validate(); | |
| jQuery("form.validate-form").validate(); |
| regex: /^\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i | ||
| }); | ||
| }); | ||
| } No newline at end of file |
There was a problem hiding this comment.
Nit: the file no longer ends with a newline.
| regex: /^\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i | ||
| }); | ||
| }); | ||
| } No newline at end of file |
There was a problem hiding this comment.
Optional, not for this PR: since roller.js also loads on public weblog pages, a guard around any page-specific setup that stays in here (for example, only running it when window.jQuery && jQuery.validator exist and form.validate-form is on the page) would stop this kind of error from coming back the next time a block is added.
|
Hope its ok now. btw if you don't like my changes, I don't mind "changes to my changes" to make it work, as it stops more to and frow time wasting on such a minor mod. Really just a heads up. Cheers |
Move validate email address to page rather than global roller.js. Stops template js errors and unnecessary checking.
".validate-email" class check seems only to be in one place.