Skip to content

Commit 2845816

Browse files
authored
Version: 1.8.4 (#94)
* Security - Improve URL checks in REST controller.
1 parent dc36e13 commit 2845816

File tree

5 files changed

+80
-39
lines changed

5 files changed

+80
-39
lines changed

changelog.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
= 1.8.1, May 16 2022 =
2+
* Improved the support for right-to-left languages.
3+
4+
= 1.8.0, May 02 2022 =
5+
* New block: added the Content Slider block.
6+
7+
= 1.7.10, Apr 26 2022 =
8+
* Added the ability to add a link to the Background Featured Image template part block.
9+
* Fixed an issue with the font size picker.
10+
* Fixed an issue when content of Post Slider and Post Carousel blocks may disappear in the block editor.
11+
12+
= 1.7.9, Mar 16 2022 =
13+
* Improved compatibility with WordPress 5.9.
14+
* Increased the maximum number of slides in the Media & Text Slider block.
15+
* Fixed an issue when the first slide's content may have disappeared in the Media & Text Slider block.
16+
* Fixed an issue with the slide content class in the Media & Text Slider block.
17+
* Fixed an issue with the button width in the Button Group block.
18+
* Fixed an issue when some blocks may have not been displayed in the block inserter.
19+
20+
= 1.7.8, Dec 14 2021 =
21+
* Minor bugfixes and improvements of the Google Maps, Table and Image Slider blocks.
22+
23+
= 1.7.7, Nov 2 2021 =
24+
* Fixed an issue with the empty terms list in the Custom Post Type and related blocks.
25+
26+
= 1.7.6, Oct 27 2021 =
27+
* Security - sanitization and escaping.
28+
129
= 1.7.5, Oct 1 2021 =
230
* Security - added nonces to prevent CSRF.
331

getwid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Getwid
44
* Plugin URI: https://motopress.com/products/getwid/
55
* Description: Extra Gutenberg blocks for building seamless and aesthetic websites in the WordPress block editor.
6-
* Version: 1.8.3
6+
* Version: 1.8.4
77
* Author: MotoPress
88
* Author URI: https://motopress.com/
99
* License: GPLv2 or later

includes/rest-api.php

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function register_rest_route(){
7171
}
7272

7373
public function permissions_check( $request ) {
74-
if ( ! current_user_can( 'read' ) ) {
74+
if ( ! current_user_can( 'edit_posts' ) ) {
7575
return new \WP_Error(
7676
'rest_forbidden',
7777
esc_html__( 'Forbidden.' ),
@@ -165,7 +165,7 @@ public function templates_schema() {
165165

166166
public function get_remote_templates() {
167167

168-
$cache = sanitize_text_field( wp_unslash( $_GET['cache'] ) );
168+
$cache = isset( $_GET['cache'] ) ? sanitize_text_field( wp_unslash( $_GET['cache'] ) ) : 'refresh';
169169
$templates_data = [];
170170

171171
if ($cache == 'cache'){
@@ -207,18 +207,21 @@ public function get_remote_templates() {
207207
}
208208

209209
public function get_remote_content() {
210-
$get_content_url = esc_url_raw( $_GET['get_content_url'] );
210+
211+
$get_content_url = isset( $_GET['get_content_url'] ) ? esc_url_raw( $_GET['get_content_url'] ) : false;
212+
213+
if ( ! $this->content_url_is_valid( $get_content_url ) ) {
214+
return __( 'Please provide a valid URL.', 'getwid' );
215+
}
211216

212217
//Get Templates from remote server
213218
$response = wp_remote_get(
214219
$get_content_url,
215220
array(
216221
'timeout' => 15,
217-
)
222+
)
218223
);
219224

220-
// var_dump( wp_remote_retrieve_body( $response ) ); exit();
221-
222225
$templates_data = json_decode( wp_remote_retrieve_body( $response ) );
223226

224227
//JSON valid
@@ -289,4 +292,35 @@ public function get_templates($object) {
289292
}
290293
return $return;
291294
}
295+
296+
private function content_url_is_valid( $url ) {
297+
298+
$parsed_url = wp_parse_url( $url );
299+
300+
if ( ! $parsed_url ) {
301+
return false;
302+
}
303+
304+
$valid_hosts = array( 'elements.getwid.getmotopress.com' );
305+
$valid_path = '/wp-json/getwid-templates-server/v1/get_content';
306+
307+
$remote_library_url = wp_parse_url( $this->remote_template_library_url );
308+
309+
if ( $remote_library_url && isset( $remote_library_url['host'] ) ) {
310+
$valid_hosts[] = $remote_library_url['host'];
311+
}
312+
313+
$host_is_valid = false;
314+
$path_is_valid = false;
315+
316+
if ( isset( $parsed_url['host'] ) && in_array( $parsed_url['host'], $valid_hosts ) ) {
317+
$host_is_valid = true;
318+
}
319+
320+
if ( isset( $parsed_url['path'] ) && $valid_path == $parsed_url['path'] ) {
321+
$path_is_valid = true;
322+
}
323+
324+
return $host_is_valid && $path_is_valid;
325+
}
292326
}

languages/getwid.pot

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ msgstr ""
99
"MIME-Version: 1.0\n"
1010
"Content-Type: text/plain; charset=UTF-8\n"
1111
"Content-Transfer-Encoding: 8bit\n"
12-
"POT-Creation-Date: 2023-01-26T15:31:47+02:00\n"
12+
"POT-Creation-Date: 2023-04-13T12:51:34+03:00\n"
1313
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1414
"X-Generator: WP-CLI 2.7.1\n"
1515
"X-Domain: getwid\n"
@@ -227,7 +227,7 @@ msgstr ""
227227
#: includes/blocks/instagram.php:152
228228
#: includes/instagram-token-manager.php:84
229229
#: includes/rest-api.php:201
230-
#: includes/rest-api.php:228
230+
#: includes/rest-api.php:231
231231
msgid "Error in json_decode."
232232
msgstr ""
233233

@@ -419,6 +419,10 @@ msgstr ""
419419
msgid "No templates found in Trash"
420420
msgstr ""
421421

422+
#: includes/rest-api.php:214
423+
msgid "Please provide a valid URL."
424+
msgstr ""
425+
422426
#: includes/scripts-manager.php:70
423427
msgid "Full Size"
424428
msgstr ""

readme.txt

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Contributors: MotoPress
33
Donate link: https://motopress.com/
44
Tags: gutenberg, gutenberg blocks, wordpress blocks, blocks, editor, block, gutenberg library, templates, page builder, section, google maps, mailchimp, acf
55
Requires at least: 5.5
6-
Tested up to: 6.0
6+
Tested up to: 6.1
77
Requires PHP: 5.6
8-
Stable tag: 1.8.2
8+
Stable tag: 1.8.4
99
License: GPLv2 or later
1010
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1111

@@ -182,6 +182,9 @@ Getwid plugin is distributed under the terms of the GNU GPL.
182182

183183
== Changelog ==
184184

185+
= 1.8.4, Apr 13 2023 =
186+
* Security - Improve URL checks in REST controller.
187+
185188
= 1.8.3, Jan 26 2023 =
186189
* Improved accessibility of the Video Popup block.
187190
* Added the ability to load block assets outside Getwid.
@@ -197,34 +200,6 @@ Getwid plugin is distributed under the terms of the GNU GPL.
197200
* Fixed an issue with the Image Slider block not being initialized if added from the Template Library.
198201
* Minor bugfixes and improvements.
199202

200-
= 1.8.1, May 16 2022 =
201-
* Improved the support for right-to-left languages.
202-
203-
= 1.8.0, May 02 2022 =
204-
* New block: added the Content Slider block.
205-
206-
= 1.7.10, Apr 26 2022 =
207-
* Added the ability to add a link to the Background Featured Image template part block.
208-
* Fixed an issue with the font size picker.
209-
* Fixed an issue when content of Post Slider and Post Carousel blocks may disappear in the block editor.
210-
211-
= 1.7.9, Mar 16 2022 =
212-
* Improved compatibility with WordPress 5.9.
213-
* Increased the maximum number of slides in the Media & Text Slider block.
214-
* Fixed an issue when the first slide's content may have disappeared in the Media & Text Slider block.
215-
* Fixed an issue with the slide content class in the Media & Text Slider block.
216-
* Fixed an issue with the button width in the Button Group block.
217-
* Fixed an issue when some blocks may have not been displayed in the block inserter.
218-
219-
= 1.7.8, Dec 14 2021 =
220-
* Minor bugfixes and improvements of the Google Maps, Table and Image Slider blocks.
221-
222-
= 1.7.7, Nov 2 2021 =
223-
* Fixed an issue with the empty terms list in the Custom Post Type and related blocks.
224-
225-
= 1.7.6, Oct 27 2021 =
226-
* Security - sanitization and escaping.
227-
228203
--------
229204

230205
[See the previous changelogs here](https://plugins.svn.wordpress.org/getwid/trunk/changelog.txt).

0 commit comments

Comments
 (0)