WordPress.org

Ready to get started?Download WordPress

Forums

Root Relative URLs
Blacklist URLs not working (8 posts)

  1. hccdev
    Member
    Posted 1 year ago #

    The blacklist URLs component of this plugin is not working. It's still reading all of my blacklisted urls as relative urls.

    http://wordpress.org/extend/plugins/root-relative-urls/

  2. Clocktower Media
    Member
    Posted 11 months ago #

    I can attest to that. I have a plugin that is saving a URL for maps.google.com and this information is being removed from the URL output on the frontend of the site referencing the Google maps script.

    Can you provide any insight on the exact entry that would be necessary within the blacklist URLs section?

  3. eric-o
    Member
    Posted 11 months ago #

    i am having trouble figuring out how to add to the blacklist alltogether. I am not finding that a panel shows up to add this. How are you adding to the blacklist?

  4. eric-o
    Member
    Posted 11 months ago #

    Ok, this is ugly and hackerish, but it looks to me like the plugin tends to clobber external urls in scripts…it just strips off the URL path, and assumes that all paths to enqueued javascripts are internal.

    Well, so, if you are willing to use the blacklist on the General settings page for both internal pages that shouldn't be read and for external scripts, it seems to work fine to replace the proper_root_relative_url function in the plugin with one that blocks those scripts from being considered.

    So here's the code I used:

    static function proper_root_relative_url($url) {
            //This method is used for urls that can be acceptably reformatted into root-relative urls without causing issues
            //related to other deficiencies in the wp core.
    		// HACK : EWO added middle term to if statement below, changed return string on first clause.
    		$url_parsed=@parse_url($url);  $host_plus_path=$url_parsed['host'] . $url_parsed['path'];
    
    		if (self::$massage) {
                //massage back to absolute because we're rendering a feed and the platform mixes url procurment methods between the delivery methods
                //despite offering _rss specific filters
    
                return $url;
    	 // return MP_WP_Root_Relative_URLS::dynamic_absolute_url($url);
            } elseif ( (string)stripos(get_option('emc2_blacklist_urls'), $host_plus_path ) !== "")  {
    	            self::$massage = true;
    				#error_log("url REJECTED" . $url  );
    				return $url;
    
    		} else {
                $url = @parse_url($url);
    
                if (!isset($url['path'])) $url['path'] = '';
    
                return '/' . ltrim(@$url['path'], '/') .
                    (isset($url['query']) ? "?" . $url['query'] : '') .
                    (isset($url['fragment']) ? '#' . $url['fragment'] : '');
            }
        }

    I know little about wordpress, so use this at your own risk!

    The only drawback I now see to this plugin is that it totally doesn't respect any sistemap generators that I can find. If someone knows a way around hit, please let me know!

    cheers,

    Eric

  5. mark_at_kaazing
    Member
    Posted 9 months ago #

    @marcuspope: could you review and comment? Thank you.

    I am also encountering a similar issue with blacklist URLs:
    http://wordpress.org/support/topic/plugin-is-truncating-an-externalremote-url?replies=5#post-4377886

  6. mark_at_kaazing
    Member
    Posted 9 months ago #

    Could anyone provide a working example of how the Blacklist URL section should be used? It mentions full URLs, one per line.

    Thanks!

  7. jasontremblay
    Member
    Posted 5 months ago #

    I had the same problem. I expected blacklisted URLs to be excluded when urls are being rewritten to root-relative.

    I tried the solution proposed by @eric-o, but it didn't work for me. I ended up hacking t he plugin by adding this to the proper_root_relative_url function:

    $blacklist_urls = split("\n", get_option('emc2_blacklist_urls'));
    foreach ($blacklist_urls as $x) {
        if (stripos($url, $x) !== false) {
            self::$massage = true;
            return $url;
        }
    }
  8. esmi
    Theme Diva & Forum Moderator
    Posted 5 months ago #

    @jasontremblay: As per the Forum Welcome, please post your own topic.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic