Skip to content

Commit

Permalink
Early exit in buildHttpQuery()
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
  • Loading branch information
kamil-tekiela committed Mar 12, 2023
1 parent 31ec124 commit 384cccc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libraries/classes/Url.php
Expand Up @@ -228,7 +228,7 @@ public static function getCommonRaw(array $params = [], $divider = '?', $encrypt

$query = self::buildHttpQuery($params, $encrypt);

if (($divider !== '?' && $divider !== '&') || strlen($query) > 0) {
if (($divider !== '?' && $divider !== '&') || $query !== '') {

Check warning on line 231 in libraries/classes/Url.php

View workflow job for this annotation

GitHub Actions / Infection (8.1, ubuntu-latest)

Escaped Mutant for Mutator "NotIdentical": --- Original +++ New @@ @@ $params['lang'] = $GLOBALS['lang']; } $query = self::buildHttpQuery($params, $encrypt); - if ($divider !== '?' && $divider !== '&' || $query !== '') { + if ($divider === '?' && $divider !== '&' || $query !== '') { return $divider . $query; } return '';

Check warning on line 231 in libraries/classes/Url.php

View workflow job for this annotation

GitHub Actions / Infection (8.1, ubuntu-latest)

Escaped Mutant for Mutator "NotIdentical": --- Original +++ New @@ @@ $params['lang'] = $GLOBALS['lang']; } $query = self::buildHttpQuery($params, $encrypt); - if ($divider !== '?' && $divider !== '&' || $query !== '') { + if ($divider !== '?' && $divider === '&' || $query !== '') { return $divider . $query; } return '';

Check warning on line 231 in libraries/classes/Url.php

View workflow job for this annotation

GitHub Actions / Infection (8.1, ubuntu-latest)

Escaped Mutant for Mutator "LogicalAnd": --- Original +++ New @@ @@ $params['lang'] = $GLOBALS['lang']; } $query = self::buildHttpQuery($params, $encrypt); - if ($divider !== '?' && $divider !== '&' || $query !== '') { + if ($divider !== '?' || $divider !== '&' || $query !== '') { return $divider . $query; } return '';
return $divider . $query;
}

Expand All @@ -241,6 +241,10 @@ public static function getCommonRaw(array $params = [], $divider = '?', $encrypt
*/
public static function buildHttpQuery($params, $encrypt = true): string
{
if ($params === []) {
return '';
}

$GLOBALS['config'] ??= null;

$separator = self::getArgSeparator();
Expand Down Expand Up @@ -320,7 +324,7 @@ public static function getArgSeparator($encode = 'none'): string
$arg_separator = (string) ini_get('arg_separator.input');
if (str_contains($arg_separator, ';')) {
$separator = ';';
} elseif (strlen($arg_separator) > 0) {
} elseif ($arg_separator !== '') {
$separator = $arg_separator[0];
} else {
$separator = '&';
Expand Down

0 comments on commit 384cccc

Please sign in to comment.