-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40b578e
commit e07b6e2
Showing
4 changed files
with
17 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
<?php | ||
|
||
package TgUtils; | ||
namespace TgUtils; | ||
|
||
/** | ||
* An interface for not filtering string at all. | ||
*/ | ||
public class DummyStringFilter implements StringFilter { | ||
class DummyStringFilter implements StringFilter { | ||
|
||
public static $INSTANCE = new DummyStringFilter(); | ||
public static $INSTANCE; | ||
|
||
public __construct() { | ||
public function __construct() { | ||
} | ||
|
||
/** | ||
* Filters the given string and returns sanitized value. | ||
* @param string $s - string to sanitize (can be null) | ||
* @return the sanitized string. | ||
*/ | ||
public filter($s) { | ||
public function filter($s) { | ||
return $s; | ||
} | ||
|
||
} | ||
|
||
DummyStringFilter::$INSTANCE = new DummyStringFilter(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
<?php | ||
|
||
package TgUtils; | ||
namespace TgUtils; | ||
|
||
/** | ||
* An interface for filter strings from any HTML tags. | ||
*/ | ||
public class NoHtmlStringFilter implements StringFilter { | ||
class NoHtmlStringFilter implements StringFilter { | ||
|
||
public static $INSTANCE = new NoHtmlStringFilter(); | ||
public static $INSTANCE; | ||
|
||
public __construct() { | ||
public function __construct() { | ||
} | ||
|
||
/** | ||
* Filters the given string and returns sanitized value. | ||
* @param string $s - string to sanitize (can be null) | ||
* @return the sanitized string. | ||
*/ | ||
public filter($s) { | ||
public function filter($s) { | ||
if ($s == NULL) return $s; | ||
return strip_tags($s); | ||
} | ||
|
||
} | ||
NoHtmlStringFilter::$INSTANCE = new NoHtmlStringFilter(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
<?php | ||
|
||
package TgUtils; | ||
namespace TgUtils; | ||
|
||
/** | ||
* An interface for filter strings from evil input. | ||
*/ | ||
public interface StringFilter { | ||
interface StringFilter { | ||
|
||
/** | ||
* Filters the given string and returns sanitized value. | ||
* @param string $s - string to sanitize (can be null) | ||
* @return the sanitized string. | ||
*/ | ||
public filter($s); | ||
public function filter($s); | ||
|
||
} | ||
|