* [PATCH 2/2] www: prevent '!important' in BOFH-specified CSS
2019-02-23 10:56 6% ` [PATCH 0/2] ensure user CSS always overrides BOFH CSS Eric Wong
@ 2019-02-23 10:56 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2019-02-23 10:56 UTC (permalink / raw)
To: meta; +Cc: Dmitry Alexandrov, Mateusz Loskot
CSS specified by the BOFH must never take precedence over
what a user sets in userContent.css.
---
lib/PublicInbox/WWW.pm | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index cbaf884..7ed4f65 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -512,8 +512,9 @@ sub stylesheets_prepare ($$) {
if (defined $attr->{href}) {
$inline_ok = 0;
} else {
- open(my $fh, '<', $_) or do {
- warn "failed to open $_: $!\n";
+ my $fn = $_;
+ open(my $fh, '<', $fn) or do {
+ warn "failed to open $fn: $!\n";
next;
};
my ($key) = (m!([^/]+?)(?:\.css)?\z!i);
@@ -523,6 +524,13 @@ sub stylesheets_prepare ($$) {
$ctime = sprintf('%x',(stat($fh))[10]);
$local = $mini->($local);
}
+
+ # do not let BOFHs override userContent.css:
+ if ($local =~ /!\s*important\b/i) {
+ warn "ignoring $fn since it uses `!important'\n";
+ next;
+ }
+
$css_map->{$key} = $local;
$attr->{href} = "$upfx$key.css?$ctime";
if (defined($attr->{title})) {
--
EW
^ permalink raw reply related [relevance 7%]
* [PATCH 0/2] ensure user CSS always overrides BOFH CSS
@ 2019-02-23 10:56 6% ` Eric Wong
2019-02-23 10:56 7% ` [PATCH 2/2] www: prevent '!important' in BOFH-specified CSS Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2019-02-23 10:56 UTC (permalink / raw)
To: meta; +Cc: Dmitry Alexandrov, Mateusz Loskot
First, ensure our sample CSS includes "!important" to override
what the BOFH set.
Then, make sure BOFHs can't set "!important" to override
what users set in their private CSS files.
Thanks to Dmitry Alexandrov <321942@gmail.com> for noticing
this.
Eric Wong (2):
usercontent.pm: set "!important" to override BOFH prefs
www: prevent '!important' in BOFH-specified CSS
lib/PublicInbox/UserContent.pm | 41 +++++++++++++++++++++-------------
lib/PublicInbox/WWW.pm | 12 ++++++++--
2 files changed, 35 insertions(+), 18 deletions(-)
--
EW
^ permalink raw reply [relevance 6%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2019-02-23 2:47 Default theme Eric Wong
2019-02-23 10:56 6% ` [PATCH 0/2] ensure user CSS always overrides BOFH CSS Eric Wong
2019-02-23 10:56 7% ` [PATCH 2/2] www: prevent '!important' in BOFH-specified CSS Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).