From 237a4570e2a2bbfd39520886f56c5240e6ed4bec Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Tue, 5 Aug 2014 23:52:03 +0200 Subject: Add PCRE_DOLLAR_ENDONLY to preg_match() When using preg_match() to check for a match that starts at the beginning of the string and ends at the last character of the string, we do not want to allow an additional newline character to sneak in. Amongst other potential loopholes, adding the PCRE_DOLLAR_ENDONLY modifier prevents users from registering with user names that end with a newline character. Signed-off-by: Lukas Fleischer --- web/html/pkgsubmit.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'web/html') diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 7d89425..8a48df2 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -193,7 +193,7 @@ if ($uid): /* Validate package base name. */ if (!$error) { $pkgbase_name = $pkgbase_info['pkgbase']; - if (!preg_match("/^[a-z0-9][a-z0-9\.+_-]*$/", $pkgbase_name)) { + if (!preg_match("/^[a-z0-9][a-z0-9\.+_-]*$/D", $pkgbase_name)) { $error = __("Invalid name: only lowercase letters are allowed."); } @@ -209,7 +209,7 @@ if ($uid): /* Validate package names. */ $pkg_name = $pi['pkgname']; - if (!preg_match("/^[a-z0-9][a-z0-9\.+_-]*$/", $pkg_name)) { + if (!preg_match("/^[a-z0-9][a-z0-9\.+_-]*$/D", $pkg_name)) { $error = __("Invalid name: only lowercase letters are allowed."); break; } -- cgit v1.2.3-54-g00ecf