Closed (won't fix)
Project:
Drupal core
Version:
7.x-dev
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
26 Jun 2008 at 15:36 UTC
Updated:
26 Jun 2008 at 20:23 UTC
#266488 pointed out that check_plain() is not reentrant: you can't call it several times on the same text or any &xxx; entity will get reencoded.
The contract of check_plain() is:
Encode special characters in a plain-text string for display as HTML.
It does not say anything about what to do with entities.
I suggest changing the contract so that pre-existing entities are not escaped, thus making check_plain() reentrant.
The discussion here is on:
& in a title box: display & or display &?)| Comment | File | Size | Author |
|---|---|---|---|
| check_plain-reentrant.patch | 549 bytes | damien tournoud |
Comments
Comment #1
heine commentedIt does say that (emphasis added):
check_plain operates on plaintext strings and ensures they can be displayed in an HTML context.
So, when the following plaintext string is given:
check_plain should output:
When this string is included in HTML it will be shown as:
Comment #2
damien tournoud commentedHum. I guess the dilemma is either:
Which of these two is possible? Which is the easiest?
Comment #3
damien tournoud commentedFor reference, here is the list of all calls to check_plain() in Drupal 7 (a whole bunch of them, most of them can be suspected of being reentrant): http://api.drupal.org/api/function/check_plain/7/references
Moreover,
t()calls check_plain() unconditionally when dealing with '@' and '%' modifiers, which increase the probability of having double-escaped strings.Comment #4
heine commentedAs check_plain operates explicitly on plaintext, your first proposition makes no sense. Double escaping is a sign of sloppyness. Fortunately there aren't that many double-escaping issues. The function in core most in need of fixing is theme_links and its immediate callers.
Comment #5
heine commentedt() should be though of as returning HTML
Comment #6
chx commentedcheck_plain merely runs an encoding which makes sure that a standards compliant HTML renderer software shows the exact same string you have passed in. There is nothing to fix here. If you pass in things that look like escaped HTML text to your eyes then your HTML renderer will show just that. If you think check_plain is some sort of strong AI which can figure out what to do then you are mistaken. The proposal is horribly wrong on every possible count and will introduce very strange errors.