Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit d432525a7159db48d72c7e6ac474779f6ee12eea 2 parents ca95738 + 2582ebf
@afuna afuna authored
View
4 cgi-bin/DW/Controller/Entry.pm
@@ -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
6 cgi-bin/LJ/Protocol.pm
@@ -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
2  views/entry/form.tt
@@ -214,7 +214,7 @@ postFormInitData.strings = {
id = "subject"
name = "subject"
- maxlength = "255"
+ maxlength = limits.subject_length
size = "50"
labelclass = "invisible"
Please sign in to comment.
Something went wrong with that request. Please try again.