From 9ce149f3e4cb404ccc92709fc404bee6bc31fa38 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Mon, 28 Mar 2011 11:28:32 +0200 Subject: [PATCH] Do not store truncated JSon for NL. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- include/newsletter.inc.php | 6 ++++++ modules/newsletter.php | 1 + 2 files changed, 7 insertions(+) diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 1097f59..623121f 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -829,6 +829,7 @@ class NLIssue const ERROR_INVALID_SHORTNAME = 'invalid_shortname'; const ERROR_INVALID_UFC = 'invalid_ufc'; + const ERROR_TOO_LONG_UFC = 'too_long_ufc'; const ERROR_SQL_SAVE = 'sql_error'; /** Save the global properties of this NL issue (title&co). @@ -854,6 +855,11 @@ class NLIssue } if ($this->sufb->isValid() || $this->sufb->isEmpty()) { $fields['sufb_json'] = json_encode($this->sufb->export()->dict()); + // If sufb_json is too long to be store, we do not store a truncated json and notify the user. + // The limit is LONGTEXT's one, ie 2^32 = 4294967296. + if (strlen($fields['sufb_json']) > 4294967295) { + $errors[] = self::ERROR_TOO_LONG_UFC; + } } else { $errors[] = self::ERROR_INVALID_UFC; } diff --git a/modules/newsletter.php b/modules/newsletter.php index 5428466..a7d04ee 100644 --- a/modules/newsletter.php +++ b/modules/newsletter.php @@ -238,6 +238,7 @@ class NewsletterModule extends PLModule $error_msgs = array( NLIssue::ERROR_INVALID_SHORTNAME => "Le nom court est invalide ou vide.", NLIssue::ERROR_INVALID_UFC => "Le filtre des destinataires est invalide.", + NLIssue::ERROR_TOO_LONG_UFC => "Le nombre de matricules AX renseigné est trop élevé." NLIssue::ERROR_SQL_SAVE => "Une erreur est survenue en tentant de sauvegarder la lettre, merci de réessayer.", ); -- 2.1.4