Repository navigation
Conversation
Note: I had to change the lookup from a Dictionary<string,char> to a Dictionary<string,string> in order to account for HTML entities that represent multiple Unicode characters, like ∾̳ for example. Closes #13036
There was a problem hiding this comment.
Overall the change looks good. Thank you @devatwork!
Can you please add a test which will test all entities? Ideally we would read them from http://www.w3.org/TR/html5/entities.json stored as part of the test. It will nicely test completeness.
If there's an easy way to test that we do not have "extra" entities (e.g. via reflection on the private hash), that would be great.
I would also suggest to add a compat test -- grab the old hash table and make it a test case. It will ensure we didn't accidentally modify the HTML4 list in the past and that with the new table we satisfy all those entities we had prior to this change. I know, this may be a bit paranoid from my side.
BTW: Sorry for delayed response on the review ...
|
Thanks for the feedback @karelz. I've implemented the test for the HTML4 test and it revealed an incompatibility between the HTML4 and HTML5 entity tables: the Both the dot net core and the full framework documentation do not seem to specifiy how each entity is decoded: https://msdn.microsoft.com/en-us/library/ee388354(v=vs.110).aspx and https://docs.microsoft.com/en-us/dotnet/core/api/system.net.webutility#System_Net_WebUtility_HtmlDecode_System_String_. I would prefer to use the HTML5 entities because it is the current version of the specification but I guess there are some compatibility concerns here. Any suggestions on how to move forward with this? Concerning the HTML5 Entities test: is it ok to take a dependency on |
I think that should be fine. Tests should be able to use additional libraries. At least I don't see any reason why not.
I see 3 options:
I am tempted to lean towards option 1. Option 2 is too complex (requires everyone fully understand the specs, while most people don't care about corner cases) and option 3 doesn't really help that much, while creating complexity and more compat burden for future. |
|
@davidsh @CIPop @weshaggard @terrajobst @stephentoub can one of you please chime in? |
|
Ping @davidsh @CIPop @weshaggard @terrajobst @stephentoub? @devatwork if there is no reply in next day or two, let's go with option (1) above. |
|
@karelz Ok, I understand this is not highest priority for the team right now. On my side I need to implement the reflection test and rebase. I think I will work on that somewhere at the end of the week. Out of curiosity: Is there something in place to document this change in behavior (assuming we go with 1) and even provide some guidance on what consumer of the API can do to reintroduce the old behavior by changing their consuming code. |
|
I don't have a lot of context in this area but I did want to give some general guidance and pointers. I don't really like changing the behavior of this from what we have in .NET Framework as the two will be completely different after this change. I would be OK if we made the change and also brought it to .NET Framework but if we do we would need to go with option (2) with probably a quirk to opt into HTML4 behaviors. So not knowing the details I would lean towards option (2) purely to be conservative. Lastly I wanted to point out that for legacy reasons we have two versions of this type, the one you updated System.Net.WebUtility as well as System.Web.HttpUtility. We should probably ensure some consistency between them. |
|
@weshaggard what kind of quirk options do we have here? I would love to see options "I want to target specific HTML spec" and "I want latest HTML spec". |
|
We essentially have 2 options:
|
|
@karelz I have no background on WebUtility or HttpUtility. |
|
@Eilon can you recommend anyone re HTML4 vs 5? |
|
@Tratcher not in particular, but perhaps @DamianEdwards has thoughts on what an API like this ought to do? |
|
Let's move the design discussion to the issue. |
Note: I had to change the lookup from a Dictionary<string,char> to a Dictionary<string,string> in order to account for HTML entities that represent multiple Unicode characters, like ∾̳ for example.
Closes #13036
@karelz