Browse Source

Similarly for user list and search

Visman 2 years ago
parent
commit
5d25de1145
3 changed files with 6 additions and 6 deletions
  1. 3 3
      app/Models/Pages/Search.php
  2. 2 2
      app/Models/Pages/Userlist.php
  3. 1 1
      app/Models/Search/Execute.php

+ 3 - 3
app/Models/Pages/Search.php

@@ -101,7 +101,7 @@ class Search extends Page
 
             if ($advanced) {
                 $v->addRules([
-                    'author'   => 'required|string:trim|max:25|check_author',
+                    'author'   => 'required|string:trim|max:190|check_author',
                     'forums'   => 'check_forums',
                     'serch_in' => 'required|integer|in:0,1,2',
                     'sort_by'  => 'required|integer|in:0,1,2,3',
@@ -220,7 +220,7 @@ class Search extends Page
                         'author' => [
                             'class'     => ['w1'],
                             'type'      => 'text',
-                            'maxlength' => '25',
+                            'maxlength' => '190',
                             'caption'   => 'Author search',
                             'value'     => $v->author ?? '*',
                             'required'  => true,
@@ -400,7 +400,7 @@ class Search extends Page
 
         if (
             '*' !== $name
-            && ! \preg_match('%[\p{L}\p{N}]%', $name)
+            && \preg_match('%[@\'"<>\\/\x00-\x1F]%', $name)
         ) {
             $v->addError('The :alias is not valid format');
         }

+ 2 - 2
app/Models/Pages/Userlist.php

@@ -50,7 +50,7 @@ class Userlist extends Page
                 'sort'  => $prefix . 'string|in:username,registered' . ($this->userRules->showPostCount ? ',num_posts' : ''),
                 'dir'   => $prefix . 'string|in:ASC,DESC',
                 'group' => $prefix . 'string|in:' . \implode(',', \array_keys($this->groupList)),
-                'name'  => $prefix . 'string|min:1|max:25' . ($this->userRules->searchUsers ? '' : '|in:*'),
+                'name'  => $prefix . 'string|min:1|max:190' . ($this->userRules->searchUsers ? '' : '|in:*'),
             ]);
 
         $error = true;
@@ -189,7 +189,7 @@ class Userlist extends Page
             $fields['name'] = [
                 'class'     => ['w0'],
                 'type'      => 'text',
-                'maxlength' => '25',
+                'maxlength' => '190',
                 'value'     => $v->name ?: '*',
                 'caption'   => 'Username',
                 'help'      => 'User search info',

+ 1 - 1
app/Models/Search/Execute.php

@@ -237,7 +237,7 @@ class Execute extends Method
         //???? нужен индекс по авторам сообщений/тем?
         if ('*' !== $v->author) {
             $usePIdx                 = true;
-            $vars[':author']         = \str_replace(['#', '_', '*', '?'], ['##', '#_', '%', '_'], $v->author);
+            $vars[':author']         = \str_replace(['#', '%', '_', '*', '?'], ['##', '#%', '#_', '%', '_'], $v->author);
             $whereIdx[]              = "p.poster {$like} ?s:author ESCAPE '#'";
         }