Opened 18 months ago
Closed 13 months ago
#19282 closed defect (bug) (fixed)
wp_get_attachment_link() does not allow HTML in link text
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.4 |
| Component: | General | Version: | 2.8 |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: |
Description
Attachments (2)
Change History (7)
SergeyBiryukov — 18 months ago
comment:1
SergeyBiryukov — 17 months ago
- Milestone changed from Awaiting Review to 3.4
comment:3
SergeyBiryukov — 13 months ago
I don't see a reason to escape the text here. If someone calls wp_get_attachment_link() with <script> tags, they could as well insert them into the template file directly.
That would be inconsistent with other *_link() functions which don't escape anchor text:
- the_feed_link()
- post_comments_feed_link()
- edit_term_link()
- edit_post_link()
- edit_comment_link()
- edit_bookmark_link()
- adjacent_post_link()
- get_next_posts_link()
- get_previous_posts_link()
- get_next_comments_link()
- get_previous_comments_link()
- Keywords commit added
We try to avoid kses on the frontend for performance reasons.
Removing the escaping seems appropriate here.
Note: See
TracTickets for help on using
tickets.

Letting straight HTML come through doesn't seem like the safest way to go. Why not just filter using wp_kses_post()? Not escaping allows for <script> tags to pass through, so if we want to add HTML, let's at least filter what type of HTML tags can come through. I've attached an updated diff for it.