148
seCure develoPment For mobIle APPs
//define the interface to used by all strategies
interface ContextInterface {
public function display($data);
}
//implement the first strategy that knows about HTML
class displayHTML implements ContextInterface {
public function display($data) {
echo htmlentities($data, ENT_QUOTES, "UTF-8");
echo "\n";
}}
//implement the second strategy that knows about URLs
class displayURL implements ContextInterface {
public function display($data) {
echo urlencode($data);
echo "\n";
}}
//implement the third strategy that knows about both HTML and URL
class displayBOTH implements ContextInterface {
public function display($data) {
echo htmlentities(urlencode($data), ENT_QUOTES, "UTF-8");
echo "\n";
}}
//implement a wrapper class for raw ...