mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-03 11:55:52 +01:00
Clean up POST keys containing square brackets, allows for regex ranges in routes (fixes #776)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
1. [](#bugfix)
|
||||
* Fix [#1034](https://github.com/getgrav/grav/issues/1034) redirect of page creation procedure when system.home.hide_in_urls is enabled
|
||||
* Media (Page): Do not extend parent metehod for sending files since Safari and IE API for FormData don’t implement `delete` ([#772](https://github.com/getgrav/grav-plugin-admin/issues/772))
|
||||
* Clean up POST keys containing square brackets, allows for regex ranges in routes ([#776](https://github.com/getgrav/grav-plugin-admin/issues/776))
|
||||
|
||||
# v1.2.2
|
||||
## 09/08/2016
|
||||
|
||||
@@ -2490,6 +2490,8 @@ class AdminController
|
||||
unset($post['_json']);
|
||||
}
|
||||
|
||||
$post = $this->cleanDataKeys($post);
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
||||
@@ -2701,4 +2703,21 @@ class AdminController
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
protected function cleanDataKeys($source = []){
|
||||
$out = [];
|
||||
|
||||
if (is_array($source)) {
|
||||
foreach($source as $key => $value){
|
||||
$key = str_replace('%5B', '[', str_replace('%5D', ']', $key));
|
||||
if (is_array($value)) {
|
||||
$out[$key] = $this->cleanDataKeys($value);
|
||||
} else{
|
||||
$out[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,9 @@ export default class ArrayField {
|
||||
let keyElement = type === 'key' ? element : element.siblings('[data-grav-array-type="key"]:first');
|
||||
let valueElement = type === 'value' ? element : element.siblings('[data-grav-array-type="value"]:first');
|
||||
|
||||
let name = `${template.getName()}[${!template.isValueOnly() ? keyElement.val() : this.getIndexFor(element)}]`;
|
||||
let escaped_name = !template.isValueOnly() ? keyElement.val() : this.getIndexFor(element);
|
||||
escaped_name = escaped_name.replace(/\[/g, '%5B').replace(/]/g, '%5D');
|
||||
let name = `${template.getName()}[${escaped_name}]`;
|
||||
valueElement.attr('name', !valueElement.val() ? template.getName() : name);
|
||||
|
||||
this.refreshNames(template);
|
||||
|
||||
30
themes/grav/js/admin.min.js
vendored
30
themes/grav/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -15,6 +15,7 @@
|
||||
{% if key == '0' and text == '' %}
|
||||
{% set key = '' %}
|
||||
{% endif %}
|
||||
{% set key = key|replace({'%5B': '[', '%5D': ']'}) %}
|
||||
|
||||
<input
|
||||
data-grav-array-type="key"
|
||||
|
||||
Reference in New Issue
Block a user