From ae1b9c8a647d1090e6306cc2693f63bcf3dd51f3 Mon Sep 17 00:00:00 2001
From: Nathan Gray
Date: Wed, 7 Sep 2011 15:15:08 +0000
Subject: [PATCH] - Don't let tidy wrap lines - line breaks don't go inside
tags - If tidy reports errors, strip all tags so we should get some sort of
openable file
---
etemplate/inc/class.bo_merge.inc.php | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php
index cc895fb609..19c0ee98d1 100644
--- a/etemplate/inc/class.bo_merge.inc.php
+++ b/etemplate/inc/class.bo_merge.inc.php
@@ -68,6 +68,7 @@ abstract class bo_merge
'quote-ampersand' => false, // Prevent double encoding
'quote-nbsp' => true, // XSLT can handle spaces easier
'preserve-entities' => true,
+ 'wrap' => 0, // Wrapping can break output
);
/**
@@ -741,7 +742,18 @@ abstract class bo_merge
{
// Clean HTML, if it's being kept
if($replace_tags && extension_loaded('tidy')) {
- $value = tidy_repair_string($value, self::$tidy_config);
+ $tidy = new tidy();
+ $cleaned = $tidy->repairString($value, self::$tidy_config);
+ // Found errors. Strip it all so there's some output
+ if($tidy->getStatus() == 2)
+ {
+ error_log($tidy->errorBuffer);
+ $value = strip_tags($value);
+ }
+ else
+ {
+ $value = $cleaned;
+ }
}
// replace
and
with CRLF (remove and CRLF)
$value = str_replace(array("\r","\n",'
','
','
'),array('','','',"\r\n","\r\n"),$value);