schultek / jaspr

Modern web framework for building websites in Dart. Supports SPAs, SSR and SSG.
https://jasprpad.schultek.de
MIT License
1.07k stars 65 forks source link

fix: add html unescape in hydrated data #250

Closed siesdart closed 1 month ago

siesdart commented 1 month ago

Description

In Jaspr, data is escaped and sent to the client while hydrating. However, there is no unescape process in the client now, so data which contain escapable characters like '&' is different from the server's original on the client. I fixed this by adding unescape progress in the client.

Type of Change

Ready Checklist

github-actions[bot] commented 1 month ago

Package Version Report

The following packages have been updated: jaspr : 0.13.3 -> 0.13.4 jaspr_builder : 0.13.3 -> 0.13.4 jaspr_cli : 0.13.3 -> 0.13.4 jaspr_tailwind : 0.2.0 -> 0.2.1 jaspr_test : 0.13.3 -> 0.13.4

schultek commented 1 month ago

I indeed missed the unescaping. However this can be a simple string replace operation since the only things that are escaped are

So something like str.replaceAll('&lt;', '<').replaceAll('&gt;', '>').replaceAll('&amp;', '&) or some more optimized version of that.

siesdart commented 1 month ago

I modified the code as you said. Does it look better?