Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_xhtmlcleanup
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19216/serendipity_event_xhtmlcleanup
Modified Files:
serendipity_event_xhtmlcleanup.php
Log Message:
fix xhtmlcleanup plugin to fully cleanup xhtml-code and to properly match non-closed <img> tags.
Index: serendipity_event_xhtmlcleanup.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_xhtmlcleanup/serendipity_event_xhtmlcleanup.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- serendipity_event_xhtmlcleanup.php 1 Jul 2004 18:35:18 -0000 1.4
+++ serendipity_event_xhtmlcleanup.php 9 Aug 2004 08:47:01 -0000 1.5
@@ -85,12 +85,16 @@
switch($event) {
case 'frontend_display':
foreach ($this->markup_elements as $temp) {
+ echo 'Checkking XHTML cleanup<br/>';
if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']])) {
+ echo 'Applying XHTLM cleanup.<br />';
$element = $temp['element'];
$this->cleanup_tag = 'IMG';
$this->cleanup_checkfor = 'ALT';
$this->cleanup_val = '';
- $eventData[$element] = preg_replace_callback('@(<img.+/>)@imsU', array($this, 'clean_tag'), $eventData[$element]);
+ // Basic cleanup (core s9y functionality)
+ $eventData[$element] = xhtml_cleanup($eventData[$element]);
+ $eventData[$element] = preg_replace_callback('@(<img.+/?>)@imsU', array($this, 'clean_tag'), $eventData[$element]);
$eventData[$element] = preg_replace_callback("@<a(.*)href=(\"|')([^\"']+)(\"|')@isUm", array($this, 'clean_htmlspecialchars'), $eventData[$element]);
}
}
@@ -109,17 +113,15 @@
// Takes an input tag and search for ommitted attributes. Expects a single tag (array, index 0)
function clean_tag($data) {
+ echo 'Clean tag:<br/>' . htmlentities(print_r($data, true)) . '<br/>';
// Restore tags from preg_replace_callback buffer, as those can't be passed in the function header
$tag = &$this->cleanup_tag;
$checkfor = &$this->cleanup_checkfor;
$val = &$this->cleanup_val;
- // Basic cleanup (core s9y functionality)
- $pdata = xhtml_cleanup($data[0]);
-
// Instead of nasty regex-mangling we use the XML parser to get the attribute list of our input tag
$p = xml_parser_create();
- @xml_parse_into_struct($p, $pdata, $vals, $index);
+ @xml_parse_into_struct($p, $data[0], $vals, $index);
xml_parser_free($p);
// Check if the xml parser returned anything useful
|