Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/compiler/PhutilSearchQueryCompiler.php
Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | foreach ($results as $result) { | ||||
$tokens[] = PhutilSearchQueryToken::newFromDictionary($result); | $tokens[] = PhutilSearchQueryToken::newFromDictionary($result); | ||||
} | } | ||||
return $tokens; | return $tokens; | ||||
} | } | ||||
private function tokenizeQuery($query) { | private function tokenizeQuery($query) { | ||||
$maximum_bytes = 1024; | $maximum_bytes = 1024; | ||||
if ($query === null) { | |||||
$query = ''; | |||||
} | |||||
$query_bytes = strlen($query); | $query_bytes = strlen($query); | ||||
valerio.bozzolan: Wow, finally a place where `strlen()` was really needed!
Please just do something like this… | |||||
if ($query_bytes > $maximum_bytes) { | if ($query_bytes > $maximum_bytes) { | ||||
throw new PhutilSearchQueryCompilerSyntaxException( | throw new PhutilSearchQueryCompilerSyntaxException( | ||||
pht( | pht( | ||||
'Query is too long (%s bytes, maximum is %s bytes).', | 'Query is too long (%s bytes, maximum is %s bytes).', | ||||
new PhutilNumber($query_bytes), | new PhutilNumber($query_bytes), | ||||
new PhutilNumber($maximum_bytes))); | new PhutilNumber($maximum_bytes))); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 391 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
Wow, finally a place where strlen() was really needed!
Please just do something like this before the strlen: