Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/whitemagicsoftware.com.git

Escapes inputs

AuthorDave Jarvis <email>
Date2026-02-08 23:04:12 GMT-0800
Commit2d703a390c72c845a67162eba8e2f092108638bb
Parent664c057
keenquotes/index.php
$CMD = "timeout 5 $JAVA_HOME/bin/java $JAVA_OPTS -jar $KEENQUOTES";
+$source = "";
+
if( $_SERVER[ 'REQUEST_METHOD' ] == 'POST' ) {
- $source = $_POST[ 'source' ];
+ $source = isset( $_POST[ 'source' ] ) ? $_POST[ 'source' ] : "";
}
?>
input[type="text"], textarea {
- background-color: #44464C;
+ background-color: #44464C;
color: #fff;
}
<textarea id="source" name="source" rows="5" cols="60" autofocus><?php
if( !empty( $source ) ) {
- echo $source;
+ echo htmlspecialchars( $source, ENT_QUOTES, 'UTF-8' );
}
?></textarea>
<?php
}
-else {
+elseif( !empty( $source ) ) {
/* stdin, stdout, stderr */
- $descriptors = array(
+ $descriptors = array(
0 => array( "pipe", "r" ),
1 => array( "pipe", "w" ),
}
else {
- echo "<p id='output' class='output'>$stdout</p>";
+ echo "<p id='output' class='output'>" .
+ htmlspecialchars( $stdout, ENT_QUOTES, 'UTF-8' ) . "</p>";
}
}
var textarea = document.createElement( "textarea" );
textarea.value = text;
-
+
textarea.style.top = "0";
textarea.style.left = "0";
Delta10 lines added, 7 lines removed, 3-line increase