Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Apache Roller — Changes

### Bug fixes

- **Remove Move jQuery validate email address from roller.js and add to page**
Validation should be done on the pages that need ie have an email field, rather than in the global
roller.js. Stops js errors on pages with no jquery-validate js script.

## 6.1.7

### Improvements
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/webapp/WEB-INF/jsps/core/CreateWeblog.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,27 @@

$( document ).ready(function() {

jQuery("form.validate-form").validate();
// Added method to check valid email address and add a custom error message
jQuery.validator.addMethod(
"regex",
function(value, element, regexp) {
if (regexp && regexp.constructor != RegExp) {
regexp = new RegExp(regexp);
} else if (regexp.global) {
regexp.lastIndex = 0;
}
return this.optional(element) || regexp.test(value);
}
);
// Applied email rules to field with class name validate-email
jQuery( ".validate-email" ).rules( "add", {
minlength: 3,
maxlength: 255,
email: true,
regex: /^\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gregh3269 gregh3269 Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

image

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>
`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

});

saveButton = $("#createWeblog_0");

<s:if test="bean.theme == null">
Expand Down
22 changes: 0 additions & 22 deletions app/src/main/webapp/theme/scripts/roller.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,25 +237,3 @@ function actionErrors(html) {
return error.textContent.trim();
});
}
$(document).ready(function () {
jQuery("form.validate-form").validate();
// Added method to check valid email address and add a custom error message
jQuery.validator.addMethod(
"regex",
function(value, element, regexp) {
if (regexp && regexp.constructor != RegExp) {
regexp = new RegExp(regexp);
} else if (regexp.global) {
regexp.lastIndex = 0;
}
return this.optional(element) || regexp.test(value);
}
);
// Applied email rules to field with class name validate-email
jQuery( ".validate-email" ).rules( "add", {
minlength: 3,
maxlength: 255,
email: true,
regex: /^\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b$/i
});
});