Permalink
Browse files

Merge pull request #174 from afuna/update-page-subject-maxlength-bug4265

Give error messages when subject lines are too long
  • Loading branch information...
2 parents ca95738 + 2582ebf commit d432525a7159db48d72c7e6ac474779f6ee12eea @afuna afuna committed Dec 6, 2012
Showing with 10 additions and 2 deletions.
  1. +4 −0 cgi-bin/DW/Controller/Entry.pm
  2. +5 −1 cgi-bin/LJ/Protocol.pm
  3. +1 −1 views/entry/form.tt
@@ -433,6 +433,10 @@ sub _init {
formwidth => $formwidth eq "P" ? "narrow" : "wide",
min_animation => $min_animation ? 1 : 0,
+ limits => {
+ subject_length => LJ::CMAX_SUBJECT,
+ },
+
# TODO: Remove this when beta is over
betacommunity => LJ::load_user( "dw_beta" ),
};
View
@@ -112,6 +112,7 @@ my %e = (
"408" => [ E_TEMP, "Maximum queued posts for this community+poster combination reached." ],
"409" => [ E_PERM, "Post too large." ],
"410" => [ E_PERM, "Your trial account has expired. Posting now disabled." ],
+ "411" => [ E_PERM, "Subject too long." ],
# Server Errors
"500" => [ E_TEMP, "Internal server error" ],
@@ -1040,7 +1041,10 @@ sub common_event_validation
return fail( $err, 409 ) if $did_trim;
- $req->{'subject'} = LJ::text_trim($req->{'subject'}, LJ::BMAX_SUBJECT, LJ::CMAX_SUBJECT);
+ $did_trim = 0;
+ $req->{'subject'} = LJ::text_trim( $req->{'subject'}, LJ::BMAX_SUBJECT, LJ::CMAX_SUBJECT, \$did_trim );
+ return fail( $err, 411 ) if $did_trim;
+
foreach (keys %{$req->{'props'}}) {
# do not trim this property, as it's magical and handled later
next if $_ eq 'taglist';
View
@@ -214,7 +214,7 @@ postFormInitData.strings = {
id = "subject"
name = "subject"
- maxlength = "255"
+ maxlength = limits.subject_length
size = "50"
labelclass = "invisible"

0 comments on commit d432525

Please sign in to comment.