aboutsummaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorMikael Nordfeldth <mmn@hethane.se>2016-01-05 17:31:09 +0100
committerMikael Nordfeldth <mmn@hethane.se>2016-01-05 17:31:09 +0100
commit8ad6b8809a8d452ee36de62b73c32cba849ee036 (patch)
tree6841ffe70ab6d09865ce27748b1f2b528fbb8c22 /actions
parent9a75778b299e6ca2903fb51c0765be4dcb4f42e6 (diff)
downloadgnu-social-8ad6b8809a8d452ee36de62b73c32cba849ee036.tar
gnu-social-8ad6b8809a8d452ee36de62b73c32cba849ee036.zip
Don't abort on too long notices in Notice::saveActivity
Diffstat (limited to 'actions')
-rw-r--r--actions/newnotice.php21
1 files changed, 12 insertions, 9 deletions
diff --git a/actions/newnotice.php b/actions/newnotice.php
index 17499312fb..c4b6bfa554 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -131,6 +131,17 @@ class NewnoticeAction extends FormAction
$content = $this->scoped->shortenLinks($content);
+ // Reject notice if it is too long (without the HTML)
+ // Should we do this before or after the upload attachment link? I think before...
+ if (Notice::contentTooLong($content)) {
+ // TRANS: Client error displayed when the parameter "status" is missing.
+ // TRANS: %d is the maximum number of character for a notice.
+ throw new ClientException(sprintf(_m('That\'s too long. Maximum notice size is %d character.',
+ 'That\'s too long. Maximum notice size is %d characters.',
+ Notice::maxContent()),
+ Notice::maxContent()));
+ }
+
$upload = null;
try {
// throws exception on failure
@@ -140,15 +151,7 @@ class NewnoticeAction extends FormAction
}
Event::handle('EndSaveNewNoticeAppendAttachment', array($this, $upload, &$content, &$options));
- if (Notice::contentTooLong($content)) {
- $upload->delete();
- // TRANS: Client error displayed exceeding the maximum notice length.
- // TRANS: %d is the maximum length for a notice.
- $this->clientError(sprintf(_m('Maximum notice size is %d character, including attachment URL.',
- 'Maximum notice size is %d characters, including attachment URL.',
- Notice::maxContent()),
- Notice::maxContent()));
- }
+ // We could check content length here if the URL was added, but I'll just let it slide for now...
$act->enclosures[] = $upload->getEnclosure();
} catch (NoUploadedMediaException $e) {