forked from bozdoz/wp-plugin-leaflet-map
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* updates gitlab-ci to include jest tests * extracts sanitize functions for associative arrays * updates attributions to more secure markdown syntax only * verifies nonces in admin; resolves bozdoz#135 * updates shortcodes atts to escape with filter_var and htmlspecialchars; resolves bozdoz#136 * test the test stage * force test ci update * force update stage * update gitlab ci test job * popup_text is already escaped and set with textContent * const -> var * geojson atts are already escaped * removes unnecessary attribution changes * removes trailing commas * only test javascript when it changes * bump major version * fixes extra variables in shape popup script * update docker images * updates node dependencies * removes overwritting from all extract calls * removes unwanted HTML tags in attribution Co-authored-by: bozdoz <[email protected]>
- Loading branch information
Showing
23 changed files
with
2,918 additions
and
6,699 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
name: Node.js CI | ||
|
||
on: [push] | ||
on: | ||
pull_request: | ||
paths: | ||
- '**.js' | ||
push: | ||
paths: | ||
- '**.js' | ||
|
||
jobs: | ||
build: | ||
|
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 |
---|---|---|
|
@@ -2,8 +2,6 @@ | |
/** | ||
* Leaflet Map Class File | ||
* | ||
* PHP Version 5.5 | ||
* | ||
* @category Admin | ||
* @author Benjamin J DeLong <[email protected]> | ||
*/ | ||
|
@@ -249,7 +247,29 @@ function remove_empty_string ($var) { | |
} | ||
|
||
/** | ||
* Sanitize JSON | ||
* Sanitize any given validations, but concatenate with the remaining keys from $arr | ||
*/ | ||
public function sanitize_inclusive($arr, $validations) { | ||
return array_merge( | ||
$arr, | ||
$this->sanitize_exclusive($arr, $validations) | ||
); | ||
} | ||
|
||
/** | ||
* Sanitize and return ONLY given validations | ||
*/ | ||
public function sanitize_exclusive($arr, $validations) { | ||
// remove nulls | ||
$arr = $this->filter_null($arr); | ||
|
||
// sanitize output | ||
$args = array_intersect_key($validations, $arr); | ||
return filter_var_array($arr, $args); | ||
} | ||
|
||
/** | ||
* Sanitize JSON | ||
* | ||
* Takes options for filtering/correcting inputs for use in JavaScript | ||
* | ||
|
@@ -259,12 +279,7 @@ function remove_empty_string ($var) { | |
*/ | ||
public function json_sanitize($arr, $args) | ||
{ | ||
// remove nulls | ||
$arr = $this->filter_null($arr); | ||
|
||
// sanitize output | ||
$args = array_intersect_key($args, $arr); | ||
$arr = filter_var_array($arr, $args); | ||
$arr = $this->sanitize_exclusive($arr, $args); | ||
|
||
$output = json_encode($arr); | ||
|
||
|
@@ -288,7 +303,7 @@ public function json_sanitize($arr, $args) | |
public function get_style_json($atts) | ||
{ | ||
if ($atts) { | ||
extract($atts); | ||
extract($atts, EXTR_SKIP); | ||
} | ||
|
||
// from http://leafletjs.com/reference-1.0.3.html#path | ||
|
@@ -343,7 +358,8 @@ public function get_style_json($atts) | |
public function add_popup_to_shape($atts, $content, $shape) | ||
{ | ||
if (!empty($atts)) { | ||
extract($atts); | ||
// don't overwrite existing variables | ||
extract($atts, EXTR_SKIP); | ||
} | ||
|
||
$message = empty($message) ? | ||
|
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 |
---|---|---|
|
@@ -2,8 +2,6 @@ | |
/** | ||
* Class for getting and setting db/default values | ||
* | ||
* PHP Version 5.5 | ||
* | ||
* @category Admin | ||
* @author Benjamin J DeLong <[email protected]> | ||
*/ | ||
|
@@ -15,6 +13,8 @@ | |
|
||
require_once LEAFLET_MAP__PLUGIN_DIR . 'class.plugin-option.php'; | ||
|
||
// TODO: add option to reset just a single field | ||
|
||
/** | ||
* Used to get and set values | ||
* | ||
|
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.