diff --git a/plugins/phorum/htmlpurifier.php b/plugins/phorum/htmlpurifier.php index ae2c276c..f7ef2c4c 100644 --- a/plugins/phorum/htmlpurifier.php +++ b/plugins/phorum/htmlpurifier.php @@ -81,7 +81,7 @@ function phorum_htmlpurifier_format($data) $fake_data[$message_id] = $message; $fake_data = phorum_htmlpurifier_migrate($fake_data); $body = $fake_data[$message_id]['body']; - $body = str_replace("", '', $body); + $body = str_replace("\n", "\n", $body); $updated_message['body'] = $body; // save it in $body .= $signature . $edit_message; // add it back in } else { @@ -121,7 +121,7 @@ function phorum_htmlpurifier_format($data) } // ----------------------------------------------------------------------- -// This is fragile code, copied from read.php:359. It will break if +// This is fragile code, copied from read.php:596 (Phorum 5.2.6). It will break if // that is changed /** @@ -147,9 +147,9 @@ function phorum_htmlpurifier_generate_editmessage($row) { $editmessage = ''; if(isset($row['meta']['edit_count']) && $row['meta']['edit_count'] > 0) { $editmessage = str_replace ("%count%", $row['meta']['edit_count'], $PHORUM["DATA"]["LANG"]["EditedMessage"]); - $editmessage = str_replace ("%lastedit%", phorum_date($PHORUM["short_date"],$row['meta']['edit_date']), $editmessage); + $editmessage = str_replace ("%lastedit%", phorum_date($PHORUM["short_date_time"],$row['meta']['edit_date']), $editmessage); $editmessage = str_replace ("%lastuser%", $row['meta']['edit_username'], $editmessage); - $editmessage="\n\n\n\n$editmessage"; + $editmessage = "\n\n\n\n$editmessage"; } return $editmessage; } @@ -166,7 +166,10 @@ function phorum_htmlpurifier_remove_sig_and_editmessage(&$row) { // we must not process the signature or editmessage $signature = phorum_htmlpurifier_generate_sig($row); $editmessage = phorum_htmlpurifier_generate_editmessage($row); - $row['body'] = strtr($row['body'], array($signature => '', $editmessage => '')); + $replacements = array(); + if ($signature) $replacements[str_replace("\n", "\n", $signature)] = ''; + if ($editmessage) $replacements[str_replace("\n", "\n", $editmessage)] = ''; + $row['body'] = strtr($row['body'], $replacements); return array($signature, $editmessage); } @@ -174,7 +177,7 @@ function phorum_htmlpurifier_remove_sig_and_editmessage(&$row) { * Indicate that data is fully HTML and not from migration, invalidate * previous caches * @note This function used to generate the actual cache entries, but - * since there's data missing that must be deferred to the first read + * since there's data missing that must be deferred to the first read */ function phorum_htmlpurifier_posting($message) { $PHORUM = $GLOBALS["PHORUM"]; @@ -190,7 +193,8 @@ function phorum_htmlpurifier_quote($array) { $PHORUM = $GLOBALS["PHORUM"]; $purifier =& HTMLPurifier::getInstance(); $text = $purifier->purify($array[1]); - return "
\n$text\n
"; + $source = htmlspecialchars($array[0]); + return "
\n$text\n
"; } /** diff --git a/plugins/phorum/install.txt b/plugins/phorum/install.txt index d1848938..bf0e285e 100644 --- a/plugins/phorum/install.txt +++ b/plugins/phorum/install.txt @@ -23,11 +23,5 @@ process may take a long time. After installing the HTML Purifier module and then configuring 'migrate.php', navigate to Settings and click 'Migrate Signatures' to migrate all user signatures. -The version of HTML Purifier bundled with is a custom modified 2.0.1. -Do not attempt to replace it with a version equal to or less than -downloaded from the HTML Purifier website: the module will combust -spectacularly. (Greater versions, however, are okay, because the changes -made to accomodate this module have been committed to the trunk). - Visit HTML Purifier at . May the force be with you. diff --git a/plugins/phorum/migrate.bbcode.php b/plugins/phorum/migrate.bbcode.php index 58316b07..80180876 100644 --- a/plugins/phorum/migrate.bbcode.php +++ b/plugins/phorum/migrate.bbcode.php @@ -23,6 +23,6 @@ require_once(dirname(__FILE__) . "/../bbcode/bbcode.php"); * legacy markup into HTML. */ function phorum_htmlpurifier_migrate($data) { - return phorum_bb_code($data); // bbcode's 'format' hook + return phorum_mod_bbcode_format($data); // bbcode's 'format' hook } diff --git a/plugins/phorum/settings/migrate-sigs.php b/plugins/phorum/settings/migrate-sigs.php index fd990be7..700e9a9e 100644 --- a/plugins/phorum/settings/migrate-sigs.php +++ b/plugins/phorum/settings/migrate-sigs.php @@ -46,7 +46,7 @@ function phorum_htmlpurifier_migrate_sigs($offset) { $fake_data = array(array("author"=>"", "email"=>"", "subject"=>"", 'body' => $sig)); list($fake_message) = phorum_htmlpurifier_migrate($fake_data); $user['signature'] = $fake_message['body']; - if (!phorum_user_save($user)) { + if (!phorum_api_user_save($user)) { exit('Error while saving user data'); } } @@ -55,17 +55,7 @@ function phorum_htmlpurifier_migrate_sigs($offset) { // query for highest ID in database $type = $PHORUM['DBCONFIG']['type']; $sql = "select MAX(user_id) from {$PHORUM['user_table']}"; - if ($type == 'mysql') { - $conn = phorum_db_mysql_connect(); - $res = mysql_query($sql, $conn); - $row = mysql_fetch_row($res); - } elseif ($type == 'mysqli') { - $conn = phorum_db_mysqli_connect(); - $res = mysqli_query($conn, $sql); - $row = mysqli_fetch_row($res); - } else { - exit('Unrecognized database!'); - } + $row = phorum_db_interact(DB_RETURN_ROW, $sql); $top_id = (int) $row[0]; $offset += $increment;