-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
1,205 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
namespace q\willow\filter; | ||
|
||
use q\willow\core; | ||
use q\willow\core\helper as h; | ||
use q\willow; | ||
use q\willow\filter; | ||
|
||
// load it up ## | ||
\q\willow\filter\escape::__run(); | ||
|
||
class escape extends willow\filter { | ||
|
||
public static function __run(){ | ||
|
||
// filter variable ## | ||
\add_filter( 'q/willow/render/markup/variable', [ get_class(), 'variable' ], 10, 2 ); | ||
|
||
// filter tag ## | ||
\add_filter( 'q/willow/render/markup/tag', [ get_class(), 'tag' ], 10, 2 ); | ||
|
||
} | ||
|
||
|
||
// @todo - escape entire tag | ||
public static function tag( $value, $key ) { | ||
|
||
// h::log( self::$filter ); | ||
// h::log( self::$args ); | ||
|
||
/* | ||
filters stored by context->task with ->global filters and ->variable filters, stored under original [f] flag reference | ||
*/ | ||
|
||
// h::log( 'e:>Global string escaping on: '.self::$args['context'].'->'.self::$args['task'].'->'.$key ); | ||
|
||
// global first ## | ||
if( | ||
isset( self::$filter[self::$args['context']][self::$args['task']]['global']['e'] ) | ||
|| isset( self::$filter[self::$args['context']][self::$args['task']]['global']['esc'] ) | ||
|| isset( self::$filter[self::$args['context']][self::$args['task']]['global']['escape'] ) | ||
){ | ||
|
||
// h::log( 'e:>Global string escaping on: '.self::$args['context'].'->'.self::$args['task'].'->'.$key ); | ||
|
||
$value = mb_convert_encoding( $value, 'UTF-8', 'UTF-8' ); | ||
$value = htmlentities( $value, ENT_QUOTES, 'UTF-8' ); | ||
|
||
} | ||
|
||
return $value; | ||
|
||
} | ||
|
||
|
||
|
||
// @todo - escape single variable | ||
public static function variable( $value, $key ) { | ||
|
||
// h::log( self::$filter ); | ||
// h::log( self::$args ); | ||
// h::log( 'Key: '.$key ); | ||
|
||
/* | ||
filters stored by context->task with ->global filters and ->variable filters, stored under original [f] flag reference | ||
*/ | ||
|
||
// global first ## | ||
if( | ||
isset( self::$filter[self::$args['context']][self::$args['task']]['variables'][$key]['e'] ) | ||
|| isset( self::$filter[self::$args['context']][self::$args['task']]['variables'][$key]['esc'] ) | ||
|| isset( self::$filter[self::$args['context']][self::$args['task']]['variables'][$key]['escape'] ) | ||
){ | ||
|
||
// h::log( 'd:>Variable escaping on: '.self::$args['context'].'->'.self::$args['task'].'->'.$key ); | ||
|
||
// look for {{ variable }} | ||
// h::log( '$value: '.$value ); | ||
|
||
$value = mb_convert_encoding( $value, 'UTF-8', 'UTF-8' ); | ||
$value = htmlentities( $value, ENT_QUOTES, 'UTF-8' ); | ||
|
||
// h::log( '$value: '.$value ); | ||
|
||
} | ||
|
||
return $value; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.