4 ms·
Exactly, was thinking along the same lines. While I appreciate the "shipostedness" in fulfilling the task "connect to DB in CSS" by cramming whole SQL database
by myfonj 5y ago
Exactly, was thinking along the same lines.
While I appreciate the "shipostedness" in fulfilling the task "connect to DB in CSS" by cramming whole SQL database into CSS custom property and working with it using paint worklet (this would probably not even remotely cross my mind ever), with more pragmatic approach I don't see requirement of having actual database in the CSS in the original tweet, so single boring URL endpoint reading the SQL query from parameter and responding with CSS à la `:root { --result: 'whatever'; }` should accomplish given task as well, without those Houdini's stunts:
@import "sql.css?query=Robert')%3B%20DROP%20TABLE%20Students%3B--"
body::before { content: var(--result); }
(I guess browsers do URI encoding anyway, so probably no need to encode it by hand).
Or perhaps even more simple with render to image (like `<!..><svg ...><text>whatever</text></svg>`.
body::before { content: url(sql.svg?query=...); }
That paint worklet does something similar anyway, but instead of `background: paint(…);` this would be `… url(…)`.
If JS and/or strictly static server-side is a must, the sql.css / sql.svg could be handled by a service worker with that sql-asm.js at disposal.