[textpattern commit] r2971 - in development/4.0/textpattern: include lib

0 views
Skip to first unread message

codesite...@google.com

unread,
Sep 13, 2008, 2:34:26 AM9/13/08
to txp...@googlegroups.com
Author: r.wetzlmayr
Date: Fri Sep 12 23:33:59 2008
New Revision: 2971

Modified:
development/4.0/textpattern/include/txp_admin.php
development/4.0/textpattern/lib/constants.php
development/4.0/textpattern/lib/txplib_admin.php

Log:
Validate user name length upon creation.

Modified: development/4.0/textpattern/include/txp_admin.php
==============================================================================
--- development/4.0/textpattern/include/txp_admin.php (original)
+++ development/4.0/textpattern/include/txp_admin.php Fri Sep 12 23:33:59
2008
@@ -195,6 +195,13 @@

if ($name && is_valid_email($email))
{
+ list($valid, $msg) = is_valid_username($name);
+ if (!$valid)
+ {
+ admin($msg);
+ return;
+ }
+
$password = doSlash(generate_password(6));
$nonce = doSlash(md5(uniqid(mt_rand(), TRUE)));


Modified: development/4.0/textpattern/lib/constants.php
==============================================================================
--- development/4.0/textpattern/lib/constants.php (original)
+++ development/4.0/textpattern/lib/constants.php Fri Sep 12 23:33:59 2008
@@ -34,6 +34,8 @@
define('IS_FASTCGI', IS_CGI and empty($_SERVER['FCGI_ROLE']) and
empty($_ENV['FCGI_ROLE']) );
define('IS_APACHE', !IS_CGI and substr(PHP_SAPI, 0, 6) == 'apache' );

+define('USERNAME_MAX_LENGTH', 64); // set to field width of txp_users.name
+
error_reporting($old_level);
unset($old_level);


Modified: development/4.0/textpattern/lib/txplib_admin.php
==============================================================================
--- development/4.0/textpattern/lib/txplib_admin.php (original)
+++ development/4.0/textpattern/lib/txplib_admin.php Fri Sep 12 23:33:59
2008
@@ -126,4 +126,20 @@
return(gTxt('could_not_update_author').' '.htmlspecialchars($name));
}
}
+
+// -------------------------------------------------------------
+
+ function is_valid_username($name)
+ {
+ $res = array(true, gTxt('ok'));
+
+ // limit binary string length (mbstring.func_overload safe)
+ $len = (function_exists('mb_strlen')) ? mb_strlen($name, 'ASCII') :
strlen($name);
+ if ($len >= USERNAME_MAX_LENGTH)
+ {
+ $res = array(false, gTxt('username_too_long'));
+ }
+ return $res;
+ }
+
?>

Reply all
Reply to author
Forward
0 new messages