Skip to content

Commit

Permalink
Merge pull request #105 from voku/analysis-g6g33E
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
voku committed Sep 4, 2023
2 parents 9ef90f0 + 86b731f commit e2ced08
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/voku/helper/AbstractDomParser.php
Expand Up @@ -497,7 +497,6 @@ public static function replaceToPreserveHtmlEntities(string $html): string
$linksOld = [];

if (\strpos($html, 'http') !== false) {

// regEx for e.g.: [https://www.domain.de/foo.php?foobar=1&email=lars%40moelleken.org&guid=test1233312&{{foo}}#foo]
$regExUrl = '/(\[?\bhttps?:\/\/[^\s<>]+(?:\(\w+\)|[^[:punct:]\s]|\/|}|]))/i';
\preg_match_all($regExUrl, $html, $linksOld);
Expand Down
1 change: 0 additions & 1 deletion src/voku/helper/HtmlDomHelper.php
Expand Up @@ -6,7 +6,6 @@

final class HtmlDomHelper
{

/**
* @param string $html
* @param string $optionStr
Expand Down
2 changes: 0 additions & 2 deletions src/voku/helper/HtmlDomParser.php
Expand Up @@ -478,7 +478,6 @@ protected function createDOMDocument(string $html, $libXMLExtraOptions = null, $
}

if ($documentFound === false) {

// UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251
$xmlHackUsed = false;
if (\stripos('<?xml', $html) !== 0) {
Expand Down Expand Up @@ -1124,7 +1123,6 @@ static function ($value) {
$html = (string) \preg_replace_callback(
'/(?<start>(<script [^>]*type=["\']?(?:' . $tags . ')+[^>]*>))(?<innerContent>.*)(?<end><\/script>)/isU',
function ($matches) {

// Check for logic in special script tags, like [<% _.each(tierPrices, function(item, key) { %>],
// because often this looks like non-valid html in the template itself.
foreach ($this->templateLogicSyntaxInSpecialScriptTags as $logicSyntaxInSpecialScriptTag) {
Expand Down
1 change: 0 additions & 1 deletion src/voku/helper/SimpleHtmlDom.php
Expand Up @@ -831,7 +831,6 @@ protected function cleanHtmlWrapper(
||
$newDocument->getIsDOMDocumentCreatedWithoutHtmlWrapper()
) {

// Remove doc-type node.
if ($newDocument->getDocument()->doctype !== null) {
$newDocument->getDocument()->doctype->parentNode->removeChild($newDocument->getDocument()->doctype);
Expand Down
1 change: 0 additions & 1 deletion src/voku/helper/XmlDomParser.php
Expand Up @@ -204,7 +204,6 @@ protected function createDOMDocument(string $xml, $libXMLExtraOptions = null, $u
}

if ($documentFound === false) {

// UTF-8 hack: http://php.net/manual/en/domdocument.loadhtml.php#95251
$xmlHackUsed = false;
/** @noinspection StringFragmentMisplacedInspection */
Expand Down
2 changes: 1 addition & 1 deletion tests/HtmlDomParserTest.php
Expand Up @@ -362,7 +362,7 @@ public function testIssue96()
$dom = new voku\helper\HtmlDomParser();
$dom->load($html);

foreach($dom->findMulti('.mydiv .mydiv-item') as $childEl) {
foreach ($dom->findMulti('.mydiv .mydiv-item') as $childEl) {
$childEl->class = 'replaced';
}
foreach ($dom->findMulti('.mydiv') as $myDivEl) {
Expand Down
3 changes: 2 additions & 1 deletion tests/XmlDomParserTest.php
Expand Up @@ -22,7 +22,8 @@ public function testXml()
);
}

public function testXMLWithoutLoadingDtd() {
public function testXMLWithoutLoadingDtd()
{
$cxmlData = '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.024/cXML.dtd"><cXML payloadID="dsfsfsdds" timestamp="2022-12-21T15:35:02+01:00" xml:lang="en-US"><Header><From><Credential domain="NetworkId"><Identity>sdfdfsdf-123</Identity></Credential></From><To><Credential domain="NetworkId"><Identity>fsdfdsfdsfds-321</Identity></Credential></To><Sender><Credential domain="NetworkId"><Identity>fsdfdsfds-1234</Identity></Credential><UserAgent>vdmg: Moelleken, Lars (VDMG-Connect)</UserAgent></Sender></Header><Message><PunchOutOrderMessage><BuyerCookie/><PunchOutOrderMessageHeader operationAllowed="edit"><Total><Money currency="EUR">2.13</Money></Total></PunchOutOrderMessageHeader><ItemIn quantity="1"><ItemID><SupplierPartID>43423342</SupplierPartID></ItemID><ItemDetail><UnitPrice><Money currency="EUR">2.13</Money></UnitPrice><Description xml:lang="de">Stahlblech 10 mm 1200</Description><Classification domain="UNSPSC"/></ItemDetail></ItemIn></PunchOutOrderMessage></Message></cXML>';

$xmlParser = new \voku\helper\XmlDomParser();
Expand Down

0 comments on commit e2ced08

Please sign in to comment.