Skip to content

Commit

Permalink
added date as a safe function
Browse files Browse the repository at this point in the history
  • Loading branch information
Kharhamel committed Oct 22, 2020
1 parent 7026ace commit 291d8de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions generator/src/DocPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ public function detectFalsyFunction(): bool
if (preg_match('/&gd\.return\.identifier;/m', $file)) {
return true;
}
//used for date
if (preg_match('/If a non-numeric value is used for
\<parameter\>timestamp\<\/parameter\>, &false; is returned/m', $file)) {
return true;
}

//used to detect imagecreatefromstring
if (preg_match('/If the arguments are invalid, the function returns &false;/m', $file)) {
Expand Down
2 changes: 2 additions & 0 deletions generator/tests/DocPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function testDetectFalsyFunction()
$fsockopen = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/network/functions/fsockopen.xml');
$arrayReplace = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/array/functions/array-replace.xml');
$mktime = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/datetime/functions/mktime.xml');
$date = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/datetime/functions/date.xml');

$this->assertTrue($pregMatch->detectFalsyFunction());
$this->assertFalse($implode->detectFalsyFunction());
Expand All @@ -29,6 +30,7 @@ public function testDetectFalsyFunction()
$this->assertTrue($fsockopen->detectFalsyFunction());
$this->assertFalse($arrayReplace->detectFalsyFunction());
$this->assertTrue($mktime->detectFalsyFunction());
$this->assertTrue($date->detectFalsyFunction());
}

public function testDetectNullsyFunction()
Expand Down

0 comments on commit 291d8de

Please sign in to comment.