DamianEdwards / RazorSlices

Lightweight Razor-based templates for ASP.NET Core without MVC, Razor Pages, or Blazor.
MIT License
297 stars 12 forks source link

Infinite Loop when Encoding large HTML String #37

Closed tucker87 closed 1 month ago

tucker87 commented 9 months ago

In BufferWriterHtmlExtensions Line 188 you call Encode. But if it doesn't fit in the buffer you end up just looping. I fixed it locally by just upping the HtmlEncodeAllowanceRatio to 1.2 but I'm not sure this is a good solution.

String I was trying to parse: {"antiForgery":"CfDJ8PXqQxmMPkhOiAitfXYwz3Qx8ObgK9ND-yZcc0Wf5Vtyo8pylpAtos8zwLNhJ-T3gJ4m2iX96lbH15gV0LIdcEBHU5xf3U95L_rlojOvp-0XIvZ8HI3CWIr6xUIKGhDpKaasa9hMAzjUZuFjYVdDkmE","formFieldName":"__RequestVerificationToken"}

Knock 1 or 2 characters out and it works fine.

Loving the project for some HTMX stuff I'm playing with!

DamianEdwards commented 8 months ago

Thanks for the report! I suspected there'd be a bug like this somewhere in one of those methods :smile: