Skip to content

Commit 13dfca2

Browse files
committed
corrections, code coverage updates, update sanitize_path, update version
1 parent 1496813 commit 13dfca2

File tree

6 files changed

+13
-11
lines changed

6 files changed

+13
-11
lines changed

lib/Constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* ezsqlModel Constants
77
*/
8-
\defined('EZSQL_VERSION') or \define('EZSQL_VERSION', '5.1.1');
8+
\defined('EZSQL_VERSION') or \define('EZSQL_VERSION', '5.1.2');
99
\defined('OBJECT') or \define('OBJECT', 'OBJECT');
1010
\defined('ARRAY_A') or \define('ARRAY_A', 'ARRAY_A');
1111
\defined('ARRAY_N') or \define('ARRAY_N', 'ARRAY_N');

lib/ezFunctions.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,17 +607,17 @@ function is_traversal(string $basePath, string $filename)
607607
*
608608
* Example:
609609
*
610-
* `sanitize_path("../../../../config.php");`
611-
*
612-
* Returns `config.php` without the path traversal
613-
* @param string $path
610+
* `sanitize_path("../../../../config.php-");`
611+
* - Returns `config.php` without the path traversal
612+
* @param string $path original file/path to be sanitized.
614613
* @return string
615614
*/
616615
function sanitize_path(string $path)
617616
{
618617
$file = \preg_replace("/\.[\.]+/", "", $path);
619618
$file = \preg_replace("/^[\/]+/", "", $file);
620619
$file = \preg_replace("/^[A-Za-z][:\|][\/]?/", "", $file);
620+
$file = \trim($file, '.-_');
621621
return ($file);
622622
}
623623

@@ -1365,7 +1365,7 @@ function unionAll($table = '', $columnFields = '*', ...$conditions)
13651365
/**
13661366
* Specifies an ordering for the query results.
13671367
* @param string $orderBy - The column.
1368-
* @param string $order - The ordering direction.
1368+
* @param string $order - The ordering direction, either `ASC`|`DESC`.
13691369
*
13701370
* @return string - ORDER BY SQL statement, or false on error
13711371
*/

lib/ezQuery.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ public function orderBy($orderBy, $order)
269269
}
270270

271271
$columns = $this->to_string($orderBy);
272-
273-
$order = (\in_array(\strtoupper($order), array('ASC', 'DESC'))) ? \strtoupper($order) : 'ASC';
272+
$by = \strtoupper($order);
273+
$order = (\in_array($by, array('ASC', 'DESC'))) ? $by : 'ASC';
274274

275275
return 'ORDER BY ' . $columns . ' ' . $order;
276276
}

lib/ezQueryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public function unionAll(string $table = null, $columnFields = '*', ...$conditio
276276
/**
277277
* Specifies an ordering for the query results.
278278
* @param string $orderBy - The column.
279-
* @param string $order - The ordering direction.
279+
* @param string $order - The ordering direction, either `ASC`|`DESC`.
280280
*
281281
* @return string - ORDER BY SQL statement, or false on error
282282
*/

tests/ezFunctionsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function testClean_string()
7070

7171
public function testSanitize_path()
7272
{
73-
$this->assertEquals("config.php", sanitize_path("../../../../config.php"));
73+
$this->assertEquals("config.php", sanitize_path("../../../../config.php-"));
7474
}
7575

7676
public function testis_traversal()

tests/mysqli/mysqliTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
dropping,
2626
altering,
2727
get_results,
28+
limit,
29+
orderBy,
2830
replacing,
2931
table_setup,
3032
where
@@ -603,7 +605,7 @@ public function testSelectAndCreateTable()
603605
])
604606
);
605607

606-
$result = $this->object->select('users', 'id, tel_num, email', eq('user_name ', 'walker'));
608+
$result = $this->object->select('users', 'id, tel_num, email', where(eq('user_name ', 'walker')), orderBy('id', 'ASC'), limit(1));
607609

608610
$this->object->debugOn();
609611
$this->expectOutputRegex('/[123456]/');

0 commit comments

Comments
 (0)