#18268 closed enhancement (fixed)
Add tel, sms, callto and fax protocols to esc_url() and make the array filterable
Reported by: | sanchothefat | Owned by: | |
---|---|---|---|
Milestone: | 3.3 | Priority: | normal |
Severity: | normal | Version: | 3.2.1 |
Component: | Formatting | Keywords: | has-patch dev-feedback |
Focuses: | Cc: |
Description
There are loads of protocols that people may need to support.
Currently esc_url() obliterates urls that don't match the allowed list _before_ it reaches the 'clean_url' filter.
This means I can't put tel: or callto: links in a menu via the admin.
The attached patch adds in some more useful protocols and makes the array filterable to cover all the protocols listed on http://en.wikipedia.org/wiki/URI_scheme
Attachments (5)
Change History (25)
#2
in reply to:
↑ 1
@
13 years ago
Replying to scribu:
+1 on the esc_url_protocols filter, but please add some spacing, as per the coding standards:
http://codex.wordpress.org/WordPress_Coding_Standards#Space_Usage
Thanks scribu, I've updated the patch including the white-space changes across the whole esc_url() function.
#3
@
13 years ago
Cool.
One more thing: next time you upload an updated version of a patch, don't overwrite the old one, to preserve context.
#5
@
13 years ago
I wonder whether it might be worth adding in some of the more popular proprietary protocols. eg. 'skype:'? Might be opening a can of worms though.
#6
@
13 years ago
@john My patch has a filter on the allowed protocols so if you wanted to you could add it. Something like skype links would be ok I think, it's widely used enough to warrant it. I should probably add im: and some others too.
#7
@
13 years ago
There's steam: teamspeak: git: spotify: gtalk: javascript: cvs: facetime: - there's even one for secondlife!
If I add an updated patch which additional protocols should be supported out of the box? Check the wikipedia link in the initial report for a reference.
#10
@
13 years ago
In IRC we discussed putting the protocols array in a wp_allowed_protocols() function and using the kses_allowed_protocols filter on it. wp_kses() and esc_url() would use this function. The function can make the array static and perform the filtering only once, avoiding thousands of apply_filters() calls.
#12
@
13 years ago
On a related note: why is wp_parse_args() used on a non-associative array in wp_kses()?
#13
follow-up:
↓ 14
@
13 years ago
The use of wp_parse_args() is indeed odd. $allowed_protocols should override the default when not empty.
#14
in reply to:
↑ 13
@
13 years ago
Replying to ryan:
$allowed_protocols should override the default when not empty.
Done in 18268.2.diff.
#17
@
13 years ago
Do we need to update http://core.trac.wordpress.org/browser/trunk/wp-admin/includes/user.php#L98 ?
#18
follow-ups:
↓ 19
↓ 20
@
12 years ago
Just added a modification of the wp_allowed_protocols()
function -- as-is, if you call the function once, say, in a plugin for whatever reason, the static is set and the filter triggers, and no other plugins / theme stuff / whatever will be able to add a filter, as empty() will always be false.
I like optimizing things as much as the next guy and caching it with static, but we could potentially be caching incomplete data.
Perhaps leave it as a static, and call doing_it_wrong() if they activate it before a certain point, to ensure everyone at the table has an opportunity to attach filters?
#19
in reply to:
↑ 18
@
12 years ago
Replying to georgestephanis:
as-is, if you call the function once, say, in a plugin for whatever reason, the static is set and the filter triggers, and no other plugins / theme stuff / whatever will be able to add a filter, as empty() will always be false.
This might be worth a new ticket. Related: #21299
#20
in reply to:
↑ 18
@
9 years ago
Replying to georgestephanis:
as-is, if you call the function once, say, in a plugin for whatever reason, the static is set and the filter triggers, and no other plugins / theme stuff / whatever will be able to add a filter, as empty() will always be false.
Follow-up: #36033
+1 on the esc_url_protocols filter, but please add some spacing, as per the coding standards:
http://codex.wordpress.org/WordPress_Coding_Standards#Space_Usage