Re: Decoding HTML and the Ambiguous Ampersand
| From: | Dennis Snell | Date: | Sat, 17 Aug 2024 20:37:45 +0000 |
| Subject: | Re: Decoding HTML and the Ambiguous Ampersand | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-125031@lists.php.net to get a copy of this message | ||
On Aug 17, 2024, at 11:20 AM, Mel Dafert <mel@dafert.at> wrote:
>
> On August 16, 2024 2:59:11 AM GMT+02:00, Dennis Snell <dennis.snell@automattic.com
> <mailto:dennis.snell@automattic.com>> wrote:
>>
>> All,
>>
>>
>> I have submitted an RFC draft for including the proposed feature from this issue. Thanks to
>> everyone who helped me in this process. It’s my first RFC, so I apologize in advance for any
>> mistakes I’ve made in the process.
>>
>>
>> https://wiki.php.net/rfc/decode_html
>>
>>
>>
>>
>> This is proposed for a future PHP version after 8.4.
>>
>>
>> Warmly,
>> Dennis Snell
>>
>
> Hello,
>
> I have just one nit: I think it would be better to use an enum for the
>
$context
> parameter rather than a constant.
This sounds like a fine idea. I was following some examples in the source code from other functions.
> It also feels like it ought to be nice to find some reasonable default... I'm sure many
> programmers will see this parameter and be
> unsure which value to use. There should, at the very least, be clear documentation with
> real-world examples in which cases which one should be
Clear documentation seems like a good avenue to both communicate what the expectations are and also
to educate on what the choices must be.
I’m very concerned about setting a default though, largely due to the way that it hides the choice
we’re making when we ask to decode. This concern comes from seeing the mistakes play out
frequently, particularly because we reach for this same function when reading attribute values and
text alike, even though that can lead to different decodes.
If we default to one context, then I have a hard time imagining that anyone would realize they are
making the choice that they are.
>
> All in all, this is definitely a welcome improvement!
>
Thanks! It’s already proven to be quite useful within the WordPress context where it came from. I
would love to see it grow into a form where PHP can have a reliable decoder that doesn’t depend on
manual intervention to work right.
> Regards,
> Mel
Have a nice weekend,
Dennis Snell