Removes BBCode from being calculated in signatures.

Stops bbcode from being calculated into the total for signatures. Also
adjusts the character limit in the text area from N, to N + BBC length.
Tested on my website.
This commit is contained in:
sk8rdude461 2015-05-28 14:02:20 -06:00
parent 0dc351fcbf
commit 1bfe0df460
2 changed files with 13 additions and 5 deletions

View File

@ -2892,7 +2892,7 @@ function profileValidateSignature(&$value)
$unparsed_signature = strtr(un_htmlspecialchars($value), array("\r" => '', '&#039' => '\''));
// Too long?
if (!empty($sig_limits[1]) && $smcFunc['strlen']($unparsed_signature) > $sig_limits[1])
if (!empty($sig_limits[1]) && (!empty($sig_bbc) ? ($smcFunc['strlen']($unparsed_signature) - $smcFunc['strlen']($sig_bbc)) : $smcFunc['strlen']($unparsed_signature)) > $sig_limits[1])
{
$_POST['signature'] = trim(htmlspecialchars($smcFunc['substr']($unparsed_signature, 0, $sig_limits[1]), ENT_QUOTES));
$txt['profile_error_signature_max_length'] = sprintf($txt['profile_error_signature_max_length'], $sig_limits[1]);

View File

@ -2549,6 +2549,11 @@ function template_profile_signature_modify()
setTimeout("tick()", 800);
}
function parseBaby(text) {
var babyless = new RegExp(/\[(\w+)[^w]*?](.*?)\[\/\1]/g);
return text.replace(babyless, "$2");
}
function calcCharLeft()
{
var maxLength = ', $context['signature_limits']['max_length'], ';
@ -2561,12 +2566,15 @@ function template_profile_signature_modify()
{
oldSignature = currentSignature;
if (currentSignature.replace(/\r/, "").length > maxLength)
document.forms.creator.signature.value = currentSignature.replace(/\r/, "").substring(0, maxLength);
if (parseBaby(currentSignature.replace(/\r/, "")).length > maxLength) {
var diff = currentSignature.replace(/\r/, "").length - parseBaby(currentSignature.replace(/\r/, "")).length;
document.forms.creator.signature.value = currentSignature.replace(/\r/, "").substring(0, maxLength+diff);
}
currentSignature = document.forms.creator.signature.value.replace(/\r/, "");
}
setInnerHTML(document.getElementById("signatureLeft"), maxLength - currentSignature.length);
var size = parseBaby(currentSignature).length;
console.log(size);
setInnerHTML(document.getElementById("signatureLeft"), maxLength - size);
}
addLoadEvent(tick);