<commit_before><?php
namespace wcf\form;
use wcf\data\user\User;
use wcf\data\user\UserAction;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\menu\user\UserMenu;
use wcf\system\user\signature\SignatureCache;
use wcf\system\WCF;

/**
 * Shows the signature edit form.
 * 
 * @author	<NAME>
 * @copyright	2001-2016 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	WoltLabSuite\Core\Form
 */
class SignatureEditForm extends MessageForm {
	/**
	 * @inheritDoc
	 */
	public $disallowedBBCodesPermission = 'user.signature.disallowedBBCodes';
	
	/**
	 * @inheritDoc
	 */
	public $loginRequired = true;
	
	/**
	 * @inheritDoc
	 */
	public $messageObjectType = 'com.woltlab.wcf.user.signature';
	
	/**
	 * @inheritDoc
	 */
	public $neededModules = ['MODULE_USER_SIGNATURE'];
	
	/**
	 * @inheritDoc
	 */
	public $showSignatureSetting = false;
	
	/**
	 * parsed signature cache
	 * @var	string
	 */
	public $signatureCache;
	
	/**
	 * @inheritDoc
	 */
	public $templateName = 'signatureEdit';
	
	/**
	 * @inheritDoc
	 */
	public function readParameters() {
		parent::readParameters();
		
		// get max text length
		$this->maxTextLength = WCF::getSession()->getPermission('user.signature.maxLength');
	}
	
	/**
	 * @inheritDoc
	 */
	public function validate() {
		if (WCF::getUser()->disableSignature) throw new PermissionDeniedException();
		
		AbstractForm::validate();
		
		if (!empty($this->text)) {
			$this->validateText();
		}
	}
	
	/**
	 * @inheritDoc
	 */
	public function readData() {
		parent::readData();
		
		// default values
		if (empty($_POST)) {
			$this->text = WCF::getUser()->signature;
		}
		
		$this->signatureCache = SignatureCache::getInstance()->getSignature(WCF::getUser());
	}
	
	/**
	 * @inheritDoc
	 */
	public function assignVariables() {
		parent::assignVariables();
		
		WCF::getTPL()->assign([
			'signatureCache' => $this->signatureCache
		]);
	}<commit_msg>Fix saving empty signature<commit_after><?php
namespace wcf\form;
use wcf\data\user\User;
use wcf\data\user\UserAction;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\html\input\HtmlInputProcessor;
use wcf\system\menu\user\UserMenu;
use wcf\system\user\signature\SignatureCache;
use wcf\system\WCF;

/**
 * Shows the signature edit form.
 * 
 * @author	<NAME>
 * @copyright	2001-2016 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @package	WoltLabSuite\Core\Form
 */
class SignatureEditForm extends MessageForm {
	/**
	 * @inheritDoc
	 */
	public $disallowedBBCodesPermission = 'user.signature.disallowedBBCodes';
	
	/**
	 * @inheritDoc
	 */
	public $loginRequired = true;
	
	/**
	 * @inheritDoc
	 */
	public $messageObjectType = 'com.woltlab.wcf.user.signature';
	
	/**
	 * @inheritDoc
	 */
	public $neededModules = ['MODULE_USER_SIGNATURE'];
	
	/**
	 * @inheritDoc
	 */
	public $showSignatureSetting = false;
	
	/**
	 * parsed signature cache
	 * @var	string
	 */
	public $signatureCache;
	
	/**
	 * @inheritDoc
	 */
	public $templateName = 'signatureEdit';
	
	/**
	 * @inheritDoc
	 */
	public function readParameters() {
		parent::readParameters();
		
		// get max text length
		$this->maxTextLength = WCF::getSession()->getPermission('user.signature.maxLength');
	}
	
	/**
	 * @inheritDoc
	 */
	public function validate() {
		if (WCF::getUser()->disableSignature) throw new PermissionDeniedException();
		
		AbstractForm::validate();
		
		if (!empty($this->text)) {
			$this->validateText();
		}
		else {
			$this->htmlInputProcessor = new HtmlInputProcessor();
			$this->htmlInputProcessor->process($this->text, $this->messageObjectType, WCF::getUser()->userID);
		}
	}
	
	/**
	 * @inheritDoc
	 */
	public function readData() {
		parent::readData();
		
		// default values
		if (empty($_POST)) {
			$this->text = WCF::getUser()->signature;
		}
		
		$this->signatureCache = SignatureCache::getInstance()->getSignature(WCF::getUser());
	}
	
	/**
	 * @inheritDoc
	 */
	public function assignVariables() {
		parent::assignVariables();
		
		WCF::getTPL()->assign([
			'signatureCache' => $this->signatureCache
		]);
	}
{'fraction_non_alphanumeric': 0.15952095808383235, 'fraction_numerical': 0.0038323353293413173, 'mean_word_length': 3.7889908256880735, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6814251', 'n_tokens_mistral': 1500, 'n_tokens_neox': 1300, 'n_words': 242}