===== WikkaWiki => SafeHTML ===== == Umstellung von alter PHP-Version == Meldung: ##Fatal error: Uncaught Error: Attempt to modify property "handler_default" on null in /usr/local/www/wdb/3rdparty/core/safehtml/classes/HTMLSax.php:556...## und noch viel länger (statt 556 auch 494) Lösung: nicht so einfach... ((1)) Neuere Version von //safehtml// nehmen Bei [[https://github.com/WackoWiki/wackowiki WackoWiki]] wird SafeHTML wohl entwickelt. Der Versuch, die neueste Version von dort in 1.4.2 zu integrieren, schlug fehl. Deshalb sind die nachstehend genannten Schritte obsolet => Lösung weiter unten! //Einbindung neuer Version - einzelne Schritte: ((2)) Neue Version bei Wacko-Wiki geholt ((2)) Unter ##3rdparty/core/safehtml/## gespeichert ((2)) Änderungen bei Einbindung: in ##libs / wakka.class.php##: => ##function ReturnSafeHTML($html)## ab ca. Zeile 712 in ##wikka.config.php##: => ##'safehtml_path' => '3rdparty/safehtml',## (ca. Zeile 35) (Pfad auf neue Version geändert) in ##3rdparty / safehtml / safehtml.php## => alle includes wurden direkt eingespeichert (HTMLSax3, Decorate, States)// ---- Nach Erläuterung bei Wacko-Wiki wird es so eingebunden: ##Example: $parser = new SafeHTML; $result = $parser->parse($doc); ## Benötigt wird aber auch HTMLSax3 - mit folgenden Dateien:## _HTMLSax3 |_HTMLSax3.php |_HTMLSax3 |_Decorators.php |_States.php ## ((1)) Wie wird SafeHTML in WikkaWiki allgemein eingebunden Folgende Dateien sind betroffen / hier taucht ein Verweis darauf auf: Variablen: - wikka.php - wikka.config.php Funktionen werden aufgerufen: - formatters / wakka.php (2x) - formatters / html.php (2x) - libs / Wakka.class.php (viele) - actions / rss / rss.php - actions / image / image.php - actions / files / files.php - actions / googleform / googleform.php - actions / textsearchexpanded / textsearchexpanded.php Sonstige: - lang / en / FormattingRules.txt - lang / pl / FormattingRules.txt Ergebnis von ##grep -r -i "safehtml" wdb##: ## wdb/wikka.php: 'safehtml_path' => '3rdparty/core/safehtml', wdb/wikka.config.php: 'safehtml_path' => '3rdparty/core/safehtml', wdb/setup/inc/db_update_mysql.php: rmdirr("safehtml"); wdb/formatters/wakka.php: // SafeHTML will treat this but 'raw' may end up with invalid code! wdb/formatters/wakka.php: return $wakka->ReturnSafeHTML($newembedded); wdb/formatters/html.php: // SafeHTML will treat this but 'raw' may end up with invalid code! wdb/formatters/html.php: return $wakka->ReturnSafeHTML($newembedded); wdb/libs/Wakka.class.php: * @uses Config::$safehtml_path wdb/libs/Wakka.class.php: * @uses SafeHTML::parse() wdb/libs/Wakka.class.php: function ReturnSafeHTML($html) wdb/libs/Wakka.class.php: $safehtml_classpath = $this->GetConfigValue('safehtml_path').'/classes/safehtml.php'; wdb/libs/Wakka.class.php: require_once $safehtml_classpath; wdb/libs/Wakka.class.php: $safehtml = instantiate('safehtml'); wdb/libs/Wakka.class.php: $filtered_output = $safehtml->parse($html); wdb/libs/Wakka.class.php.save: * @uses Config::$safehtml_path wdb/libs/Wakka.class.php.save: * @uses SafeHTML::parse() wdb/libs/Wakka.class.php.save: function ReturnSafeHTML($html) wdb/libs/Wakka.class.php.save: #print $safehtml_classpath; wdb/libs/Wakka.class.php.save: #$safehtml = instantiate('safehtml'); wdb/libs/Wakka.class.php.save: #$filtered_output = $safehtml->parse($html); wdb/libs/Wakka.class.php.save: $safehtml_classpath = $this->GetConfigValue('safehtml_path').DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.'safehtml.php'; wdb/libs/Wakka.class.php.save: require_once $safehtml_classpath; wdb/libs/Wakka.class.php.save: $safehtml = instantiate('safehtml'); wdb/libs/Wakka.class.php.save: $filtered_output = $safehtml->parse($html); wdb/lang/pl/defaults/FormattingRules.txt:Domyślnie niektóre polecenia HTML są usuwane, celem zabezpieczenia przed potencjalnie niebezpiecznym kodem. Więcej informacji na ten temat: Wikka:SafeHTML. wdb/lang/en/defaults/FormattingRules.php:printf(T_('By default, some HTML tags are removed by the %s parser to protect against potentially dangerous code. The list of tags that are stripped can be found on the %s page.'), '""SafeHTML""', 'Wikka:SafeHTML'); wdb/actions/rss/rss.php: * @uses Wakka::ReturnSafeHTML() wdb/actions/rss/rss.php: echo $this->ReturnSafeHTML($cached_output); wdb/actions/image/image.php:/* 6) Return the output. We don't need ReturnSafeHTML anymore. */ wdb/actions/table/table.php: * @uses Wakka::ReturnSafeHTML() wdb/actions/table/table.php: echo $this->ReturnSafeHTML($cached_output); wdb/actions/googleform/googleform.php:// Sanitization: Passing $query to htmlspecialchars_ent instead of ReturnSafeHTML(). Inside the value parameter of the input field, wdb/actions/files/files.php: * @uses Wakka::ReturnSafeHTML() wdb/actions/files/files.php: //Although $output is passed to ReturnSafeHTML, it's better to sanitize $text here. At least it can avoid invalid XHTML. wdb/actions/files/files.php: $output = $this->ReturnSafeHTML($output); wdb/actions/files/files.php: $output = $this->ReturnSafeHTML($output); wdb/actions/textsearchexpanded/textsearchexpanded.php: * @uses Wakka::ReturnSafeHtml() wdb/actions/textsearchexpanded/textsearchexpanded.php:$result_page_list = $this->ReturnSafeHtml($result_page_list); wdb/3rdparty/core/safehtml/classes/HTMLSax_old.php: If you'll use unmodified HTMLSax, Safehtml will be NOT SAFE! wdb/3rdparty/core/safehtml/classes/safehtml.php: SafeHTML Parser. wdb/3rdparty/core/safehtml/classes/safehtml.php: http://pixel-apes.com/safehtml wdb/3rdparty/core/safehtml/classes/safehtml.php:class safehtml { wdb/3rdparty/core/safehtml/classes/safehtml.php: function safehtml() { wdb/3rdparty/core/safehtml/classes/HTMLSax.php: If you'll use unmodified HTMLSax, Safehtml will be NOT SAFE! wdb/3rdparty/core/safehtml/readme.txt:SafeHTML wdb/3rdparty/core/safehtml/readme.txt:http://pixel-apes.com/safehtml wdb/3rdparty/core/safehtml/readme.txt:Please, subscribe to http://pixel-apes.com/safehtml/feed/rss feed in order to receive notices wdb/3rdparty/core/safehtml/readme.txt:when SAFEHTML will be updated. wdb/3rdparty/core/safehtml/readme.txt: * New array, closeParagraph, contains list of block-level elements. When we open such elemet, we should close paragraph before. . It allows SafeHTML to produce more XHTML compliant code. wdb/3rdparty/core/safehtml/readme.txt: * Now SafeHTML strips down table elements when we are not inside table. wdb/3rdparty/core/safehtml/readme.txt: * Now SafeHTML correctly closes unclosed "li" tags: before opening "li" of the same nesting level. wdb/3rdparty/core/safehtml/readme.txt: Bug fix: safehtml hangs on code. Binary file wdb/sql/wikka_sqlite3.db matches## ((1)) Zweiter Anlauf mit Verbesserung des ursprünglichen Codes Dieser Versuch war erfolgreich: ((2)) Code für Klassen verbessert Die meisten Stellen können mit dem Tool [[https://github.com/rectorphp/rector rector]] korrigiert werden. => es mussten Konstruktoren in allen Klassen neu geschrieben werden und => ferner einige Deklarationen von Arrays ((2)) Problem des Konstruktors bei Vererbung! Nach Umsetzung der standardmäßigen Korrekturen (Vorschlag rector) kam immer noch ein Fehler bei ca. Zeile 300 in der Funktion ##_parse($state = XML_HTMLSAX_STATE_START)## => ##$state = $this->State[$state]->parse($this);##. **offensichtliches Problem**: Die Klassen, die von der Klasse ##XML_HTMLSax_StateParser## in ##HTMLSax.php## abgeleitet werden (=> ##XML_HTMLSax_StateParser_Gtet430## und - eigentlich obsolet - ##XML_HTMLSax_StateParser_Lt430##) **Lösung**: explizit die Konstruktion-Routine der Parent-Klasse aufrufen: ##parent::""__""construct($htmlsax);##