Browse Source

Escape output. New ActionDoubleEntityDecode.

master
Adam Backstrom 9 years ago
parent
commit
a58513cb59
  1. 17
      classes.php
  2. 16
      index.php

17
classes.php

@ -68,6 +68,21 @@ class ActionBase64Encode extends AbstractAction
}
}
class ActionDoubleEntityDecode extends AbstractAction
{
public function __construct( $value )
{
parent::__construct( $value );
$this->setContainer( new TextareaContainer );
$this->setFormatter( new EchoFormatter );
}
public function decode()
{
return html_entity_decode( html_entity_decode( $this->value, ENT_QUOTES, 'UTF-8' ), ENT_QUOTES, 'UTF-8' );
}
}
class ActionBase64Decode extends AbstractAction
{
public function __construct( $value )
@ -145,7 +160,7 @@ class TextareaContainer extends DivContainer
{
public function wrap( $contents )
{
return parent::wrap( '<textarea>' . $contents . '</textarea>' );
return parent::wrap( '<textarea>' . htmlentities($contents) . '</textarea>' );
}
}

16
index.php

@ -20,9 +20,10 @@ require_once 'functions.php';
<?php
$action = null;
$action_str = isset($_POST['action']) ? $_POST['action'] : null;
if( 'POST' === $_SERVER['REQUEST_METHOD'] ) {
$class = "Action" . $_POST['action'];
$class = "Action" . $action_str;
$action = new $class( $_POST['data'] );
}
@ -33,12 +34,13 @@ if( 'POST' === $_SERVER['REQUEST_METHOD'] ) {
<form method="post">
<textarea class="data" name="data"><?php if( $action ) echo $action->esc_raw(); ?></textarea><br>
<select name="action">
<option value="QuotedPrintableDecode" <?php echo selected($_POST['action'], 'QuotedPrintableDecode'); ?>>quoted_printable_decode()</option>
<option value="Urlencode" <?php echo selected($_POST['action'], 'Urlencode'); ?>>urlencode()</option>
<option value="Urldecode"<?php echo selected($_POST['action'], 'Urldecode'); ?>>urldecode()</option>
<option value="Unserialize"<?php echo selected($_POST['action'], 'Unserialize'); ?>>unserialize()</option>
<option value="Base64Decode"<?php echo selected($_POST['action'], 'Base64Decode'); ?>>base64_decode()</option>
<option value="Base64Encode"<?php echo selected($_POST['action'], 'Base64Encode'); ?>>base64_encode()</option>
<option value="DoubleEntityDecode" <?php echo selected($action_str, 'DoubleEntityDecode'); ?>>html_entity_decode(html_entity_decode())</option>
<option value="QuotedPrintableDecode" <?php echo selected($action_str, 'QuotedPrintableDecode'); ?>>quoted_printable_decode()</option>
<option value="Urlencode" <?php echo selected($action_str, 'Urlencode'); ?>>urlencode()</option>
<option value="Urldecode"<?php echo selected($action_str, 'Urldecode'); ?>>urldecode()</option>
<option value="Unserialize"<?php echo selected($action_str, 'Unserialize'); ?>>unserialize()</option>
<option value="Base64Decode"<?php echo selected($action_str, 'Base64Decode'); ?>>base64_decode()</option>
<option value="Base64Encode"<?php echo selected($action_str, 'Base64Encode'); ?>>base64_encode()</option>
<select>
<input type="submit">
</form>

Loading…
Cancel
Save