Repository navigation
Artikel: Infoboxen als Kasten, Bilder in passender Größe - #278
Merged
Merged
Conversation
cvui/infobox gets a box rule in articles/blocks.ts that keeps its contents in a div with the class infobox, the one class the gate keeps on a div; the reader stylesheet fills and edges it with semantic tokens. The gate keeps srcset and sizes on img: every srcset candidate is parsed the way the HTML standard reads it, its address held to the rule src gets and written out absolute, its descriptor to a width or a density, and a failing candidate is dropped rather than the attribute passed through. Offline bundle regenerated, article cache namespace raised to articles-3. Closes #276
… the gate did A security review of #278 found that htmlparser2 and a browser read an infobox inside a list item differently: an inner li closes the outer one and the box with it, and the box's end tag then closes the reader's own wrapper. The gate now keeps a box only at the top of the body and an li only straight inside a list. reader-gate.test.ts parses every corpus body's reader document with parse5 and asserts the wrapper is followed by the footer. A break at either edge of a paragraph is dropped, which the site's infoboxes open with. Offline bundle regenerated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Worum es geht: Zwei Stellen, an denen ein Artikel in der App schlechter aussah oder langsamer lud als auf correctiv.org.
Was sich ändert:
Nach der Sicherheitsprüfung: Ein Kasten bleibt nur dann ein Kasten, wenn er ganz oben im Artikeltext steht, nicht verschachtelt in einer Liste oder einem Zitat. Sonst konnte ein präparierter Text den Browser dazu bringen, den Kasten anders zu schließen als unser Filter, und der Rest des Artikels stand außerhalb der Lesedarstellung. Ein verschachtelter Kasten verliert nur seine Hinterlegung, der Text bleibt. Außerdem entfallen die Leerzeilen am Anfang der Absätze in den Infoboxen.
Beides betrifft auch die Artikel, die offline in der App mitgeliefert werden; die sind neu erzeugt. Artikel, die schon auf einem Gerät zwischengespeichert sind, werden einmal neu geladen, damit sie die Kästen und Bildgrößen auch bekommen.
Infobox, hell und dunkel (Einstellung „System“, Gerät hell bzw. dunkel):
Bild aus mehreren Größen, hell und dunkel: geladen wurde
594531575-1160x1160.jpgstatt594531575-scaled.jpg(2560 px).Closes #276
Technische Details
blocks.ts: neue Aktionbox.cvui/infobox(Markerwp-block-cvui-infobox) wird zu<div class="infobox">mit seinem Inhalt, in beiden Interpretern (String und DOM). Das Panel wird wie bisher ausgepackt, der Knopf „Mehr anzeigen“ fällt wie bisher weg.body-allowlist.ts: eindivbleibt nur, wenn es eine Klasse ausREADER_BOX_CLASSESträgt, und dann nur mit dieser einen Klasse. Jedes anderedivwird wie bisher ausgepackt.srcsetundsizesanimg:srcsetwird Kandidat für Kandidat so gelesen wie im HTML-Standard (Adresse bis zum nächsten Leerraum, Kommas darin gehören zur Adresse, ein Komma am Ende beendet den Kandidaten). Jede Adresse geht durch dieselbe Prüfung wiesrc(nur http/https, relativ gegen correctiv.org aufgelöst und absolut ausgeschrieben), der Deskriptor muss eine Breite oder Dichte sein. Ein Kandidat, der durchfällt, fällt weg; bleibt keiner, fällt das Attribut weg. Geschrieben wird aus den Teilen neu, nie der Wert, wie er kam.sizesbleibt nur mit Zeichen einer Längenliste.<source>bleibt draußen wie bisher.reader-gate.test.ts: Tabelle umsrcset,sizesunddiv.infoboxerweitert, die Eigenschaftsprüfung prüft jede Adresse insrcset. Neue Korpus-Einträge:javascript:,data:text/html(auch base64),vbscript:, Tab im Schema, offene Anführungszeichen, Kommas in Adressen, falsche Deskriptoren, feindlichessizes,div.infoboxmit Stil und Handler. Alle vier Wege (Cache, REST, beide Extraktoren).div.infoboxnur auf oberster Ebene des Texts,linur direkt inul/ol. Grund: htmlparser2 kennt die impliziten End-Tags des HTML-Standards kaum,<ul><li><div class="infobox"><li>schloss im Browser Kasten und damitdiv.reader-body.reader-gate.test.tsparst jetzt jedes Korpus-Dokument mit parse5 (neue devDependency von app-core, lag schon im Baum) und prüft, dass auf.reader-bodydirekt der Footer folgt und jeder Kasten direkt darin steht. Neue Fälle:srcsetmit Adresse, die nach dem Trimmen auf Komma endet,span.infobox,img src="mailto:".<br>am Rand eines<p>fällt weg.reader-html.ts:.infoboxmit--var-color-surfaceals Fläche und--var-color-strokeals Rand, beides semantisch und damit im Dunkelmodus mitgehend.CACHE_NSaufarticles-3: ein vor dieser Änderung gespeicherter, gescrapter Artikel hat weder Kasten nochsrcset.npm run offline-articlesneu erzeugt,offline-bundle.test.tsgrün.npm run checkgrün; Web-Export (build:web,serve-clean.mjs) in Chrome, Einstellung „System“ gegen helles und dunkles Gerät,currentSrcder Bilder abgelesen. Nicht geprüft: Android und iOS nativ.🤖 Generated with Claude Code