Browse Source

Limit PM max length

We encrypt PMs, so if the encrypted text is truncated by mysql, the
entire message is destroyed. Truncate it before encryption so that
doesn't happen
spaghetti 8 years ago
parent
commit
50605ee4ec
2 changed files with 2 additions and 2 deletions
  1. 1
    1
      classes/misc.class.php
  2. 1
    1
      sections/inbox/compose.php

+ 1
- 1
classes/misc.class.php View File

50
     $UnescapedSubject = $Subject;
50
     $UnescapedSubject = $Subject;
51
     $UnescapedBody = $Body;
51
     $UnescapedBody = $Body;
52
     $Subject = db_string($Subject);
52
     $Subject = db_string($Subject);
53
-    $Body = DBCrypt::encrypt($Body);
53
+    $Body = DBCrypt::encrypt(substr($Body, 0, 49135)); // 49135 -> encryption -> 65536 (max length in mysql)
54
     if ($ToID == 0) {
54
     if ($ToID == 0) {
55
       // Don't allow users to send messages to the system
55
       // Don't allow users to send messages to the system
56
       return;
56
       return;

+ 1
- 1
sections/inbox/compose.php View File

41
         <h3>Subject</h3>
41
         <h3>Subject</h3>
42
         <input type="text" class="required" name="subject" size="95" value="<?=(!empty($Subject) ? $Subject : '')?>" /><br />
42
         <input type="text" class="required" name="subject" size="95" value="<?=(!empty($Subject) ? $Subject : '')?>" /><br />
43
         <h3>Body</h3>
43
         <h3>Body</h3>
44
-        <textarea id="body" class="required" name="body" cols="95" rows="10" onkeyup="resize('body')"><?=(!empty($Body) ? $Body : '')?></textarea>
44
+        <textarea id="body" class="required" name="body" cols="95" rows="10" maxlength="49000" onkeyup="resize('body')"><?=(!empty($Body) ? $Body : '')?></textarea>
45
       </div>
45
       </div>
46
       <div id="preview" class="hidden"></div>
46
       <div id="preview" class="hidden"></div>
47
       <div id="buttons" class="center">
47
       <div id="buttons" class="center">

Loading…
Cancel
Save