Plugin Directory


Ignore:
Timestamp:
10/14/2026 06:21:08 AM (3 days ago)
Author:
iulianp
Message:

release 1.3.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • image-hub/trunk/inc/src/MediaModal.php

    r3308961 r3745452  
    3333    public function image_hub_enqueue_media_library_scripts($id = '')
    3434    {
    35         if (is_admin()) {
     35        if (is_admin() && current_user_can('upload_files')) {
    3636            Utils::enque_image_hub_script('media-modal', false);
    3737
    … …  
    6363                }
    6464
     65                if (!current_user_can('upload_files')) {
     66                        wp_send_json_error('You are not allowed to upload files.', 403);
     67                }
     68
    6569        // call the callback url to notify provider that image is downloaded (unsplash terms)
    6670        //https://help.unsplash.com/en/articles/2511258-guideline-triggering-a-download
    … …  
    6872            $callback_url = esc_url_raw(wp_unslash($_POST['downloadImageCallbackUrl']));
    6973
    70             if (filter_var($callback_url, FILTER_VALIDATE_URL)) {
    71                 $response = wp_remote_get($callback_url);
     74            // The callback always goes through the image service, so any other host is ignored.
     75            $service_host = wp_parse_url(Utils::get_service_url(), PHP_URL_HOST);
     76
     77            if (filter_var($callback_url, FILTER_VALIDATE_URL) && $service_host && wp_parse_url($callback_url, PHP_URL_HOST) === $service_host) {
     78                // A dev service can run on localhost, which wp_safe_remote_get() refuses.
     79                $response = defined('IMAGE_HUB_DEV_SERVICE_URL') ? wp_remote_get($callback_url) : wp_safe_remote_get($callback_url);
    7280                if (is_wp_error($response)) {
    7381                    wp_send_json_error('Failed to fetch data from callback URL. ' . $callback_url);
Note: See TracChangeset for help on using the changeset viewer.