aclist / kbin-kes

Add-on manager and scripting framework for kbin
MIT License
24 stars 8 forks source link

[Mod] Unsanitize CSS (another kbin bugfix) #266

Closed Pamasich closed 6 months ago

Pamasich commented 6 months ago

Kbin currently allows magazines to declare custom CSS that is applied while viewing them, and users can also change the CSS of the site in their settings.

This behavior is currently bugged however. Any CSS defined this way gets HTML escaped, causing certain characters like > and & to be replaced with HTML escape codes. This causes any CSS rule that uses them to not actually work, causing confusion and imposing unnecessary limitations on what can be achieved.

Until kbin fixes this bug themselves, I've implemented this fix as a mod.

I doubt this has a lot of use on its own currently, especially with how underused CSS is on kbin in the first place. And anyone who tests their code wouldn't have CSS that needs this mod running on their magazine anyway. For user CSS, I recommend userstyles over kbin's builtin functionality anyway. This is very much a "just in case" mod with the reason I'm implementing it now being to act as a dependency (so a use case for the discussed depends_on, once that's implemented) for another bugfix mod which needs to know which style tag contains the magazine CSS.

Add-ons (mods):

aclist commented 6 months ago

Is there a magazine using custom CSS you can link to?

Also, I was thinking of reorganizing the mod pages a bit and putting this and the repair codeblocks under "debug," does that seem reasonable?

Pamasich commented 6 months ago

Is there a magazine using custom CSS you can link to?

Yeah, mine.

The magazine title in the sidebar is supposed to be red as a test, but it doesn't work because I used > as a selector and that gets escaped to >. I first ran into the issue when I tried to help someone implement a magazine banner, which was way too much of a struggle to get working.

Pamasich commented 6 months ago

with the reason I'm implementing it now being to act as a dependency (so a use case for the discussed depends_on, once that's implemented) for another bugfix mod which needs to know which style tag contains the magazine CSS.

Actually I just realized that won't work like I was expecting it to... since it's not guaranteed magazine css uses > or &... So this isn't a guaranteed way to identify the magazine css style element.

Pamasich commented 6 months ago

Also, I was thinking of reorganizing the mod pages a bit and putting this and the repair codeblocks under "debug," does that seem reasonable?

Hmm, I think debug is a bit too technical a term, there's the danger that users won't look in there. I think taking the name literally it makes sense, but usually debug stuff is only meant to be used by the developer, so people who know that would probably not look in there unless they're developing their own mod.

aclist commented 6 months ago

The banner is a big red rectangle for me (with no mod applied), is that correct?

Maybe there should be a "Fixes" page. I feel like General is starting to get too cluttered with things that aren't exactly general in nature.

Pamasich commented 6 months ago

The banner is a big red rectangle for me (with no mod applied), is that correct?

Yeah, that's what I ultimately managed to throw together after other attempts failed because of this issue.

Pamasich commented 6 months ago

Maybe there should be a "Fixes" page. I feel like General is starting to get too cluttered with things that aren't exactly general in nature.

Yeah, I've been wondering if there's a better place for them too. A new Fixes category makes sense.