Skip to content
This repository has been archived by the owner on Jun 24, 2018. It is now read-only.

Commit

Permalink
actually check the length of user-submitted aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoc committed May 26, 2014
1 parent f166c52 commit d671636
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions index.php
Expand Up @@ -28,13 +28,18 @@
if ( (isset($_POST['alias'])) && (!empty(trim($_POST['alias']))) ) {
$alias = trim(strtolower($_POST['alias']));

// Check if submitted alias is sane (<= 50 characters, and alpha-numeric)
if ( (strlen($alias) > 50) || (!preg_match('/^[a-z0-9]+$/i', $alias)) ) {
$badalias = true;
}

// Set an empty alias if none was submitted
} else {
$alias = '';
}

// Check if submitted alias has sane characters
if ( (!empty($alias)) && (!preg_match('/^[a-z0-9]+$/i', $alias)) ) {
// Return error if alias was not sane
if (isset($badalias)) {
$error = 'Invalid alias';

// Require functions with blacklist/URL checks and run the URL through said checks
Expand Down Expand Up @@ -138,7 +143,7 @@
?>
<form method="post">
<input type="text" size="50" name="url" value="http://"><br>
Alias (optional): <input type="text" size="20" name="alias"><br><br>
Alias (optional): <input type="text" size="20" maxlength="50" name="alias"><br><br>
<input type="submit" value="shorten!">
<input type="reset" value="nevermind">
</form>
Expand Down

0 comments on commit d671636

Please sign in to comment.