Skip to content

Commit 477fd4c

Browse files
release: fixes
- Enhanced security - Updated dependencies
2 parents f024d7a + fc6539b commit 477fd4c

File tree

6 files changed

+83
-18
lines changed

6 files changed

+83
-18
lines changed

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/abstract/feedzy-rss-feeds-admin-abstract.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,14 @@ public function normalize_urls( $raw ) {
697697
$feed_url = apply_filters( 'feedzy_get_feed_url', $feeds );
698698
if ( is_array( $feed_url ) ) {
699699
foreach ( $feed_url as $index => $url ) {
700-
$feed_url[ $index ] = trim( $this->smart_convert( $url ) );
700+
if ( wp_http_validate_url( $url ) ) {
701+
$feed_url[ $index ] = trim( $this->smart_convert( esc_url_raw( $url ) ) );
702+
}
701703
}
704+
} elseif ( wp_http_validate_url( $feed_url ) ) {
705+
$feed_url = trim( $this->smart_convert( esc_url_raw( $feed_url ) ) );
702706
} else {
703-
$feed_url = trim( $this->smart_convert( $feed_url ) );
707+
$feed_url = '';
704708
}
705709

706710
return $feed_url;

includes/gutenberg/feedzy-rss-feeds-gutenberg-block.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,9 @@ public function feedzy_register_rest_route() {
284284
array(
285285
'methods' => 'POST',
286286
'callback' => array( $this, 'feedzy_rest_route' ),
287-
'permission_callback' => function () {
288-
return is_user_logged_in();
287+
'permission_callback' => function ( WP_REST_Request $request ) {
288+
$post_id = absint( $request->get_param( 'postId' ) );
289+
return current_user_can( 'edit_post', $post_id );
289290
},
290291
'args' => array(
291292
'url' => array(
@@ -398,12 +399,14 @@ public function feedzy_rest_route( $data ) {
398399
*/
399400
public function feedzy_sanitize_feeds( $input ) {
400401
if ( count( $input ) === 1 ) {
401-
$feed = esc_url( $input[0] );
402+
$feed = wp_http_validate_url( $input[0] );
402403
return $feed;
403404
} else {
404405
$feeds = array();
405406
foreach ( $input as $item ) {
406-
$feeds[] = esc_url( $item );
407+
if ( wp_http_validate_url( $item ) ) {
408+
$feeds[] = esc_url_raw( $item );
409+
}
407410
}
408411
return $feeds;
409412
}

js/FeedzyBlock/Editor.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,12 @@ class Editor extends Component {
194194
.filter((item) => item !== '');
195195
url = queryString.stringify({ url }, { arrayFormat: 'bracket' });
196196
}
197+
const postId = wp.data.select('core/editor').getCurrentPostId();
197198

198199
apiFetch({
199200
path: `/feedzy/v1/feed?${url}`,
200201
method: 'POST',
201-
data: this.props.attributes,
202+
data: {...this.props.attributes, postId: postId},
202203
})
203204
.then((data) => {
204205
if (this.unmounting) {
@@ -311,16 +312,20 @@ class Editor extends Component {
311312

312313
getImageURL(item, background) {
313314
let url;
314-
if (item.thumbnail && this.props.attributes.thumb === 'auto') {
315-
url = item.thumbnail;
315+
if (
316+
item.thumbnail &&
317+
this.props.attributes.thumb === 'auto' &&
318+
item.thumbnail !== item.default_img
319+
) {
320+
url = item.thumbnail.replace(/http:/g, 'https:');
316321
} else if (this.props.attributes.default) {
317322
url = this.props.attributes.default.url;
323+
} else if (item.default_img) {
324+
url = item.default_img;
318325
} else {
319326
url = window.feedzyjs.imagepath + 'feedzy.svg';
320327
}
321328

322-
url = url.replace(/http:/g, 'https:');
323-
324329
if (background) {
325330
url = 'url("' + url + '")';
326331
}

tests/e2e/specs/classic-block.spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,30 @@ test.describe('Feedzy Classic Block', () => {
124124
const image = page.locator('.feedzy-rss .rss_image img');
125125
await expect(image).toHaveAttribute('style', /aspect-ratio:\s*auto;/i);
126126
});
127+
128+
test('embed youtube video', async ({ editor, page, admin }) => {
129+
await admin.createNewPost();
130+
131+
await editor.insertBlock({
132+
name: 'feedzy-rss-feeds/feedzy-block',
133+
attributes: {
134+
feeds: 'https://www.youtube.com/feeds/videos.xml?channel_id=UCSHmNs-_UuU1CfPhSbilTZQ',
135+
max: 1,
136+
},
137+
});
138+
139+
const postId = await editor.publishPost();
140+
await page.goto(`/?p=${postId}`);
141+
142+
const rssContainer = page.locator('.rss_item').first();
143+
await expect(rssContainer).toBeVisible();
144+
145+
const youtubeLink = rssContainer
146+
.locator('a[href*="youtube.com/"]')
147+
.first();
148+
await expect(youtubeLink).toBeVisible();
149+
150+
const image = rssContainer.locator('img').first();
151+
await expect(image).toBeVisible();
152+
});
127153
});

tests/e2e/specs/import.spec.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,31 @@ test.describe('Feed Import', () => {
304304
page.locator('.attachment').count()
305305
).resolves.toBeGreaterThan(0); // We should have some imported images.
306306
});
307+
308+
test('close Feedzy Action modal when clicking outside', async ({
309+
page,
310+
}) => {
311+
await page.goto('/wp-admin/post-new.php?post_type=feedzy_imports');
312+
await tryCloseTourModal(page);
313+
314+
await page
315+
.getByRole('button', { name: 'Step 3 Map content ' })
316+
.click();
317+
318+
await expect(
319+
page.getByText('Post Title item title Item')
320+
).toBeVisible();
321+
322+
await page.getByTitle('item title').getByRole('link').click();
323+
324+
await expect(
325+
page.getByRole('heading', { name: 'Add actions to this tag' })
326+
).toBeVisible();
327+
328+
await page.locator('body').click({ position: { x: 0, y: 0 } });
329+
330+
await expect(
331+
page.getByRole('heading', { name: 'Add actions to this tag' })
332+
).not.toBeVisible();
333+
});
307334
});

0 commit comments

Comments
 (0)