Skip to content

Commit 20df566

Browse files
committed
update
1 parent 0d908ba commit 20df566

11 files changed

+564
-42
lines changed

Diff for: src/MicroweberPackages/App/Utils/Parser.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,14 @@ public function replace_url_placeholders($layout)
135135

136136
public function make_tags($layout, $options = array())
137137
{
138-
139-
if ($layout == '') {
138+
if ($layout == '') {
140139
return $layout;
141140
}
141+
142+
$layout = str_ireplace('{SITE_URL}','___mw-site-url-temp-replace-on-make-tags___', $layout);
143+
144+
145+
142146
require_once __DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'phpQuery.php';
143147

144148
$pq = \phpQuery::newDocument($layout);
@@ -261,6 +265,10 @@ public function make_tags($layout, $options = array())
261265
}
262266
}
263267

268+
$layout = str_ireplace('___mw-site-url-temp-replace-on-make-tags___','{SITE_URL}', $layout);
269+
270+
271+
264272
return $layout;
265273
}
266274

Diff for: src/MicroweberPackages/App/Utils/lib/phpQuery.php

+34-3
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,14 @@ public function load($markup, $contentType = null, $newDocumentID = null)
221221
}
222222
if ($loaded) {
223223
// $this->document->formatOutput = true;
224+
$this->document->formatOutput = false;
224225
$this->document->preserveWhiteSpace = true;
226+
227+
$this->document->validateOnParse=false;
228+
$this->document->strictErrorChecking=false;
229+
$this->document->recover=false;
230+
231+
225232
$this->xpath = new DOMXPath($this->document);
226233
$this->afterMarkupLoad();
227234

@@ -294,11 +301,21 @@ protected function documentCreate($charset, $version = '1.0')
294301
if (!$version) {
295302
$version = '1.0';
296303
}
304+
305+
libxml_use_internal_errors(true);
306+
297307
$this->document = new DOMDocument($version, $charset);
298308
$this->charset = $this->document->encoding;
299309
// $this->document->encoding = $charset;
300-
$this->document->formatOutput = true;
310+
// $this->document->formatOutput = true;
311+
$this->document->formatOutput = false;
312+
// $this->document->standalone = true;
301313
$this->document->preserveWhiteSpace = true;
314+
315+
316+
$this->document->validateOnParse=false;
317+
$this->document->strictErrorChecking=false;
318+
$this->document->recover=false;
302319
}
303320

304321
protected function loadMarkupHTML($markup, $requestedCharset = null)
@@ -378,7 +395,15 @@ protected function loadMarkupHTML($markup, $requestedCharset = null)
378395
? $this->document->loadHTML($markup)
379396
: @$this->document->loadHTML($markup); */
380397

381-
$return = @$this->document->loadHTML($markup);
398+
// $return = @$this->document->loadHTML($markup);
399+
$return = @$this->document->loadHTML($markup,
400+
LIBXML_SCHEMA_CREATE |
401+
LIBXML_HTML_NOIMPLIED |
402+
LIBXML_HTML_NODEFDTD |
403+
LIBXML_NOERROR |
404+
LIBXML_NONET |
405+
LIBXML_NOWARNING
406+
);
382407

383408
if ($return) {
384409
$this->root = $this->document;
@@ -763,6 +788,10 @@ private function documentFragmentLoadMarkup($fragment, $charset, $markup = null)
763788
.'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '
764789
.'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
765790
.'<fake xmlns="http://www.w3.org/1999/xhtml">'.$markup.'</fake>');
791+
792+
/* $fragment->loadMarkupXML('<?xml version="1.0" encoding="'.$charset.'"?>'*/
793+
// . phpQuery::$defaultDoctype.''
794+
// .'<fake xmlns="http://www.w3.org/1999/xhtml">'.$markup.'</fake>');
766795
$fragment->root = $fragment->document->firstChild->nextSibling;
767796
} else {
768797
$fragment->loadMarkupXML('<?xml version="1.0" encoding="'.$charset.'"?><fake>'.$markup.'</fake>');
@@ -5079,8 +5108,10 @@ abstract class phpQuery
50795108
*
50805109
* @var unknown_type
50815110
*/
5082-
public static $defaultDoctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
5111+
public static $defaultDoctype_old = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
50835112
"http://www.w3.org/TR/html4/loose.dtd">';
5113+
5114+
public static $defaultDoctype = '<!doctype html>';
50845115
public static $defaultCharset = 'UTF-8';
50855116

50865117
/**

Diff for: src/MicroweberPackages/Content/ContentManagerCrud.php

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace MicroweberPackages\Content;
33

44
use MicroweberPackages\Content\Repositories\ContentRepository;
5+
use MicroweberPackages\Content\Models\Content;
56
use MicroweberPackages\Database\Crud;
67
use Illuminate\Support\Facades\DB;
78
use function Opis\Closure\serialize as serializeClosure;

Diff for: src/MicroweberPackages/Content/ContentManagerHelpers.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -1065,15 +1065,14 @@ public function save_from_live_edit($post_data)
10651065

10661066
$html_to_save = $content = $this->app->parser->make_tags($html_to_save);
10671067

1068-
// AntiXSS makes bug on save convertind comments to htmlentities
1069-
// $antixss = new AntiXSS();
1070-
// $html_to_save = $content = $antixss->xss_clean($html_to_save);
1068+
//\Log::info($html_to_save);
1069+
10711070

10721071
$xssClean = new XSSClean();
10731072
$html_to_save = $content = $xssClean->clean($html_to_save);
10741073

10751074

1076-
1075+
// \Log::info($html_to_save);
10771076

10781077
if ($save_module == false and $save_global == false and $save_layout == false) {
10791078
if ($content_id) {
@@ -1135,6 +1134,8 @@ public function save_from_live_edit($post_data)
11351134
$cont_table_save[$field]=$html_to_save;
11361135
}
11371136
}
1137+
1138+
11381139
$this->app->event_manager->trigger('mw.content.save_edit', $cont_field);
11391140

11401141
$to_save = array();
@@ -1371,6 +1372,7 @@ public function save_content_field($data, $delete_the_cache = true)
13711372
$table = $table_drafts;
13721373
}
13731374

1375+
13741376
$data = $this->app->format->strip_unsafe($data);
13751377

13761378
if (isset($data['is_draft']) and $data['is_draft'] and isset($data['url'])) {
@@ -1506,6 +1508,8 @@ public function save_content_field($data, $delete_the_cache = true)
15061508
$data['id'] = $find['id'];
15071509
}
15081510

1511+
1512+
15091513
$save = $this->app->database_manager->save($data);
15101514

15111515
$this->app->cache_manager->delete('content_fields');

0 commit comments

Comments
 (0)