Skip to content

Commit

Permalink
Merge pull request #4 from tvalimaa/use_internal_errors
Browse files Browse the repository at this point in the history
httmll 5 support
  • Loading branch information
tvalimaa authored Sep 2, 2022
2 parents fca659a + 7888b61 commit 6877375
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
29 changes: 29 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "tvalimaa/iframe_cookie_consent",
"description": "Adds Ckeditor plugin which converts Youtube iframe embeds to support cookie consent",
"type": "drupal-module",
"authors": [
{
"name": "Tuomas Välimaa (tvalimaa)",
"role": "Maintainer"
}
],
"homepage": "https://github.com/tvalimaa/iframe_cookie_consent",
"require": {
"masterminds/html5": "^2.7"
},
"repositories": [
{
"type": "package",
"package": {
"name": "masterminds/html5",
"version": "2.7.6",
"type": "drupal-library",
"dist": {
"url": "https://github.com/Masterminds/html5-php/archive/refs/tags/2.7.6.zip",
"type": "zip"
}
}
}
]
}
5 changes: 3 additions & 2 deletions src/Plugin/Filter/IframeCookieConsent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
use Masterminds\HTML5;

/**
* Provides a filter to help celebrate good times!
Expand All @@ -26,9 +27,9 @@ public function process($text, $langcode) {
// Get cookie consent category.
$consent_cat = $config->get('cookieconsent_category') ?? 'marketing';
// Load Ckeditor content to DOMDocument.
$dom = new \DOMDocument();
$html5 = new HTML5();
libxml_use_internal_errors(true);
@$dom->loadHTML(mb_convert_encoding($text, 'HTML-ENTITIES', 'UTF-8'));
$dom = $html5->loadHTML(mb_convert_encoding($text, 'HTML-ENTITIES', 'UTF-8'));
// Youtube regex pattern.
$regex_pattern = "/(youtube.com|youtu.be)\/(embed)?(\?v=)?(\S+)?/";
$match = NULL;
Expand Down

0 comments on commit 6877375

Please sign in to comment.