gutenbergtools / ebookmaker

The Project Gutenberg tool to generate EPUBs and other ebook formats.
GNU General Public License v3.0
84 stars 18 forks source link

Generated HTML5 inadequately protects h2 in header #150

Closed asylumcs closed 1 year ago

asylumcs commented 1 year ago

Reference two files on the landing page for etext 69058, the as submitted HTML and the generated HTML5. The generated HTML5 replaces the as-submitted tag with an <h2> but it inadequately protects the <h2> tag from the post-processor's CSS. An inline "style=" is used to partially protect from user's CSS but it is incomplete. It lacks assuring the default values (see this page for h2's defaults). Even that would be inadequate for this etext, since the post-processor has styled the h2 with a letter-spacing attribute, which is not in the W3C list. To close this issue, it seems that the h2 generated by the HTML5 conversion code must be hardened against user styling all h2's in CSS.

eshellman commented 1 year ago

The letter-spacing CSS attribute is allowed by PG. We could add every possible attribute to every styled element in the generated text, or we could ask the PP not to do that.

As it's likely that the generated text will be redesigned in Ebookmaker v0.13 (see discussion here: #139 ) We won't address this in v0.12.

asylumcs commented 1 year ago

Perhaps consider adding "all: initial" to tags used in the header and footer to assure that user's CSS does not get applied to header/footer elements.

eshellman commented 1 year ago

strange. the HTML5 validator doesn't like it: error: CSS: “all”: Property “all” doesn't exist.

nfenwick commented 1 year ago

Yes that's a surprise. I don't know what validator you are using to get it to fail. Its usage is described here in the CSS Cascading and Inheritance Level 3 documentation, which has REC status. It validates just fine with this validator, which is the only one I use for HTML5.

nfenwick commented 1 year ago

Whoops. Now that it's posted, I see I was logged in as Nell, not myself. --Roger

eshellman commented 1 year ago

can confirm it validates with the current nu validator. (23.1.8) I was hoping this would be easy, but maybe I need to fix my nu validator and maybe update others.

eshellman commented 1 year ago

production has 20.6.30 I have 20.6.30 online ebookmaker has 23.1.11

eshellman commented 1 year ago

As part of the header refactor, all: initial has been added to a number of styles in the header stylesheet - see ebookmaker.writers.HTMLTemplates I found that it was too big a hammer to use on everything, so it's still possible for the user's stylesheet to modify the header styling, but the use of #pg-header in the selector should minimize inadvertent style leakage.