From c9aa00f5c82e297bde082dda7954423b5ca321fb Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 24 Jul 2015 15:18:22 -0500
Subject: [PATCH] Fix error for new agents with very short email mailbox names

---
 include/class.forms.php | 4 ++--
 include/class.staff.php | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/class.forms.php b/include/class.forms.php
index bbca68a9c..c71452f57 100644
--- a/include/class.forms.php
+++ b/include/class.forms.php
@@ -3715,8 +3715,8 @@ class FreeTextField extends FormField {
 class FreeTextWidget extends Widget {
     function render($options=array()) {
         $config = $this->field->getConfiguration();
-        $class = $config['classes'] ?: 'thread-body'
-        ?><div class="<?php echo $class; ?>" style="padding:0"><?php
+        $class = $config['classes'] ?: 'thread-body bleed';
+        ?><div class="<?php echo $class; ?>"><?php
         if ($label = $this->field->getLocal('label')) { ?>
             <h3><?php
             echo Format::htmlchars($label);
diff --git a/include/class.staff.php b/include/class.staff.php
index c1ed5a32f..b5d742bac 100644
--- a/include/class.staff.php
+++ b/include/class.staff.php
@@ -1387,8 +1387,8 @@ extends AbstractForm {
 
     function getClean() {
         $clean = parent::getClean();
-        list($clean['username'],) = preg_split('/[^\w.-]/', $clean['email'], 2);
-        if (Staff::lookup($clean['username']))
+        list($clean['username'],) = preg_split('/[^\w.-]/u', $clean['email'], 2);
+        if (mb_strlen($clean['username']) < 3 || Staff::lookup($clean['username']))
             $clean['username'] = mb_strtolower($clean['firstname']);
         $clean['perms'] = array(
             User::PERM_CREATE,
-- 
GitLab