Skip to content

Commit

Permalink
Escaping URLs before they go into the DB.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Adams committed Aug 13, 2012
1 parent 3e938f9 commit 0eded74
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions classes/struts/option/image.php
Expand Up @@ -12,6 +12,8 @@ public function input_html() {
}

protected function standard_validation( $value ) {
$value = esc_url_raw( $value );

return trim( $value );
}

Expand Down
14 changes: 14 additions & 0 deletions classes/struts/option/text.php
@@ -1,6 +1,16 @@
<?php

class Struts_Option_Text extends Struts_Option {
protected $_is_url;

public function is_url( $is_url = NULL ) {
if ( NULL === $is_url )
return $this->_is_url;

$this->_is_url = $is_url;
return $this;
}

public function input_html() {
$id = esc_attr( $this->html_id() );
$name = esc_attr( $this->html_name() );
Expand All @@ -10,6 +20,10 @@ public function input_html() {
}

protected function standard_validation( $value ) {
if ( $this->is_url() ) {
$value = esc_url_raw( $value );
}

return trim( $value );
}
}

0 comments on commit 0eded74

Please sign in to comment.