#16432 closed enhancement (fixed)
Add filter to ent2ncr
Reported by: | GaryJ | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.3 | Priority: | normal |
Severity: | minor | Version: | 3.1 |
Component: | General | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
There's been several tickets regarding the use of hexadecimal numerical entities instead of decimal numerical entities - it's part of a W3C standard that Content SHOULD use the hexadecimal form of character escapes rather than the decimal form when there are both.
This patch adds hexadecimal entity support to ent2ncr()
for the existing named entities. It adds an optional second argument, and defaults to returning the decimal entities so is fully backwards compatible.
Attachments (5)
Change History (19)
#1
@
14 years ago
If there's a better performing way to pull out the entities from the $to_ncr
array that having to loop through and pull them into a new array first, then please let me know!
I thought about creating two arrays ($to_ncr
and $to_hncr
), but then figured the sets of named entities may get out of sync. If there's not much change in this function it may be fine to do that.
Alternatively, an ent2hncr()
function may be better, which ent2ncr
defers to if the 2nd argument is correctly set?
#2
@
14 years ago
Should is not Must.
I think a better solution is just to add a filter to this function so a plugin can implement the alternative behaviour.
#3
@
14 years ago
- Keywords needs-testing added
Two patches - the first is a simple filter on the return value.
The second patch approaches it a slightly different way. The issue with the first, is that for a block of text that is being running through ent2ncr()
, all of the string replacements would still be done, even if they weren't then used in the plugin filter function. By letting the plugin short circuit the function (if something truthy is being returned from the plugin filter function, return that from ent2ncr()
immediately), it improves performance.
#6
@
13 years ago
- Summary changed from Hexadecimal entity support within ent2ncr to Add filter to ent2ncr
Is it too late for this filter to go in to 3.2?
#7
@
13 years ago
- Keywords needs-testing removed
- Milestone changed from Awaiting Review to Future Release
Yes. Freeze for enhancements was about 6 weeks ago.
#9
@
13 years ago
Wasn't aware you could do a comparison against an assignment like that - handy! Patched.
#11
follow-up:
↓ 12
@
13 years ago
- Owner set to nacin
- Resolution set to fixed
- Status changed from new to closed
In [18456]:
Adds hexadecimal entity support to ent2ncr()