Ticket #890 (closed enhancement: wontfix)

Opened 7 years ago

Last modified 2 years ago

support relative paths for enclosures

Reported by: anonymousbugger Owned by: markjaquith
Priority: normal Milestone:
Component: Administration Version: 1.5
Severity: normal Keywords: needs-patch
Cc:

Description

Currently, enclosures only work automatically if the URL in a post is an absolute URL. Please make them work for relative URLs as well. For example, adding a link such as <a href="/audio/mymusic.mp3"> should create an enclosure to  http://www.myblog.com/audio/mymusic.mp3 and a link such as <a href="audio/mymusic.mp3"> should create an enclosure to  http://www.mysite.com/blogpath/audio/mymusic.mp3">

Attachments

relative_enclosures.diff Download (652 bytes) - added by markjaquith 6 years ago.

Change History

  • Patch set to No
  • Keywords bg|has-patch added
  • Owner changed from anonymous to markjaquith
  • Status changed from new to assigned
  • Milestone set to 2.1

Patch fixes it. Tested. But note that your URI in the content is still going to be relative, which will break in RSS2 (but not Atom, from what I hear).

The relative links also need to work from within pages other than the front page (ie: archive and category pages). Wouldn't this work?:

$content = str_replace(' href="/', ' href=" http://' . $_SERVERHTTP_HOST? . '/' . $_SERVERREQUEST_URI?, $content); $content = str_replace(" href='/", " href=' http://" . $_SERVERHTTP_HOST? . '/' . $_SERVERREQUEST_URI?, $content);

Oops, I meant:

$content = str_replace(' href="/', ' href=" http://' . $_SERVERHTTP_HOST? . $_SERVERREQUEST_URI?, $content);

$content = str_replace(" href='/", " href=' http://" . $_SERVERHTTP_HOST? . $_SERVERREQUEST_URI?, $content);

  • Keywords has-patch added; bg|has-patch removed

Hi Mark,

Is this still a worthwhile enhancement? Still targeted for 2.1? Does the patch need updating?

  • Keywords 2nd-opinion added

Lloyd,

Patch still works. Still think it's worthwhile, although it's done in such a way as to execute quickly, with a simple str_replace instead of a more complicated regex, so I'd like another pair of eyes to sign off on it.

The patch looks good except for one thing: both relative and absolute server paths are caught by it and (incorrectly) routed to $SERVERHTTP_HOST?, n'est ce pas? The ticket submitter requested that both relative (audio/audio.mp3) and absolute (/audio/audio.mp3) work. Would not the current solution direct both links to  http://$SERVER_URL/audio/audio.mp3, which is fine for /audio/audio.mp3 but which would be incorrect for anyone with a blog URL in any place other than the root for audio/audio.mp3. If there's no leading slash, oughtn't we just use bloginfo('url') or similar?

zamoose,

Only domain-relative paths are caught.

Assuming all other relative paths to be relative based on the 'home' setting might be okay. Anyone else?

comment:9   matt5 years ago

  • Milestone changed from 2.1 to 2.2

+1. Looks good.

  • Milestone changed from 2.2 to 2.3
  • Milestone changed from 2.3 to 2.4 (next)

A 3 year old enhancement ticket. I didn't even know WordPress has been around that long. :)

I'd close it as wontfix because of lack of traction, but both rob1n and markjaquith showed an interest in it, so I'll leave it up to them.

I'd still like this. :-) I'll tackle it for 2.4

Mark, you missed 2.4. Retry for 2.5? ;)

  • Milestone changed from 2.5 to 2.6

+1 to wontfix

  • Keywords needs-patch added; has-patch 2nd-opinion removed
  • Status changed from accepted to closed
  • Resolution set to wontfix
  • Milestone 2.9 deleted
Note: See TracTickets for help on using tickets.