Diff
checker
テキスト
テキスト
画像
ドキュメント
Excel
フォルダ
Legal
Enterprise
デスクトップ
料金
ログイン
Diffchecker デスクトップのダウンロード
テキスト比較
2 つのテキスト ファイルの違いを見つける
ツール
履歴
ライブエディター
未変更行を折りたたむ
折り返しなし
レイアウト
分割
統合
比較精度
スマート
単語
文字
シンタックスハイライト
構文を選択
無視
テキスト変換
最初の差分へ移動
入力を編集
Diffchecker Desktop
Diffcheckerを実行する最も安全な方法。Diffchecker Desktopアプリを入手:あなたの差分はコンピューターから出ることはありません!
Desktopを入手
interdiff_3360661_3382821
作成日
3 年前
差分は期限切れになりません
クリア
エクスポート
共有
説明
4 削除
行
合計
削除
文字
合計
削除
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
118 行
すべてコピー
20 追加
行
合計
追加
文字
合計
追加
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
129 行
すべてコピー
diff --git a/src/Plugin/Filter/ConvertUrlToEmbedFilter.php b/src/Plugin/Filter/ConvertUrlToEmbedFilter.php
diff --git a/src/Plugin/Filter/ConvertUrlToEmbedFilter.php b/src/Plugin/Filter/ConvertUrlToEmbedFilter.php
コピー
コピー済み
コピー
コピー済み
index d164700..
267e636
100644
index d164700..
a77c573
100644
--- a/src/Plugin/Filter/ConvertUrlToEmbedFilter.php
--- a/src/Plugin/Filter/ConvertUrlToEmbedFilter.php
+++ b/src/Plugin/Filter/ConvertUrlToEmbedFilter.php
+++ b/src/Plugin/Filter/ConvertUrlToEmbedFilter.php
コピー
コピー済み
コピー
コピー済み
@@ -116,69 +116,
65
@@ class ConvertUrlToEmbedFilter extends FilterBase {
@@ -116,69 +116,
73
@@ class ConvertUrlToEmbedFilter extends FilterBase {
// markup, especially a '>'. Therefore, remove all comment contents and add
// markup, especially a '>'. Therefore, remove all comment contents and add
// them back later.
// them back later.
_filter_url_escape_comments('', TRUE);
_filter_url_escape_comments('', TRUE);
- $text = preg_replace_callback('`<!--(.*?)-->`s', '_filter_url_escape_comments', $text);
- $text = preg_replace_callback('`<!--(.*?)-->`s', '_filter_url_escape_comments', $text);
+ $text = is_null($text) ? '' : preg_replace_callback('`<!--(.*?)-->`s', '_filter_url_escape_comments', $text);
+ $text = is_null($text) ? '' : preg_replace_callback('`<!--(.*?)-->`s', '_filter_url_escape_comments', $text);
// Split at all tags; ensures that no tags or attributes are processed.
// Split at all tags; ensures that no tags or attributes are processed.
- $chunks = preg_split('/(<.+?>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
- $chunks = preg_split('/(<.+?>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
- // PHP ensures that the array consists of alternating delimiters and
- // PHP ensures that the array consists of alternating delimiters and
- // literals, and begins and ends with a literal (inserting NULL as
- // literals, and begins and ends with a literal (inserting NULL as
- // required). Therefore, the first chunk is always text:
- // required). Therefore, the first chunk is always text:
- $chunk_type = 'text';
- $chunk_type = 'text';
- // If a tag of $ignore_tags is found, it is stored in $open_tag and only
- // If a tag of $ignore_tags is found, it is stored in $open_tag and only
- // removed when the closing tag is found. Until the closing tag is found,
- // removed when the closing tag is found. Until the closing tag is found,
- // no replacements are made.
- // no replacements are made.
- $open_tag = '';
- $open_tag = '';
-
-
- for ($i = 0; $i < count($chunks); $i++) {
- for ($i = 0; $i < count($chunks); $i++) {
- if ($chunk_type == 'text') {
- if ($chunk_type == 'text') {
- // Only process this text if there are no unclosed $ignore_tags.
- // Only process this text if there are no unclosed $ignore_tags.
- if ($open_tag == '') {
- if ($open_tag == '') {
- // If there is a match, inject a link into this chunk via the callback
- // If there is a match, inject a link into this chunk via the callback
- // function contained in $task.
- // function contained in $task.
- $chunks[$i] = preg_replace_callback(
- $chunks[$i] = preg_replace_callback(
- $pattern,
- $pattern,
- function ($match) {
- function ($match) {
- try {
- try {
- $info = \Drupal::service('url_embed')->getUrlInfo(Html::decodeEntities($match[1]));
- $info = \Drupal::service('url_embed')->getUrlInfo(Html::decodeEntities($match[1]));
- if ($info) {
- if ($info) {
コピー
コピー済み
コピー
コピー済み
- return '<drupal-url data-embed-url="' . $match[1] . '"></drupal-url>';
- }
- else {
+ $chunks = is_null($text) ? [''] : preg_split('/(<.+?>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
+ $chunks = is_null($text) ? [''] : preg_split('/(<.+?>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
+
+
+ // Do not attempt to convert links into URLs if preg_split() fails.
+ // Do not attempt to convert links into URLs if preg_split() fails.
+ if ($chunks !== FALSE) {
+ if ($chunks !== FALSE) {
+ // PHP ensures that the array consists of alternating delimiters and
+ // PHP ensures that the array consists of alternating delimiters and
+ // literals, and begins and ends with a literal (inserting NULL as
+ // literals, and begins and ends with a literal (inserting NULL as
+ // required). Therefore, the first chunk is always text:
+ // required). Therefore, the first chunk is always text:
+ $chunk_type = 'text';
+ $chunk_type = 'text';
+ // If a tag of $ignore_tags is found, it is stored in $open_tag and only
+ // If a tag of $ignore_tags is found, it is stored in $open_tag and only
+ // removed when the closing tag is found. Until the closing tag is found,
+ // removed when the closing tag is found. Until the closing tag is found,
+ // no replacements are made.
+ // no replacements are made.
+ $open_tag = '';
+ $open_tag = '';
+ for ($i = 0; $i < count($chunks); $i++) {
+ for ($i = 0; $i < count($chunks); $i++) {
+ if ($chunk_type == 'text') {
+ if ($chunk_type == 'text') {
+ // Only process this text if there are no unclosed $ignore_tags.
+ // Only process this text if there are no unclosed $ignore_tags.
+ if ($open_tag == '') {
+ if ($open_tag == '') {
+ // If there is a match, inject a link into this chunk via the callback
+ // If there is a match, inject a link into this chunk via the callback
+ // function contained in $task.
+ // function contained in $task.
+ $chunks[$i] = preg_replace_callback(
+ $chunks[$i] = preg_replace_callback(
+ $pattern,
+ $pattern,
+ function ($match) {
+ function ($match) {
コピー
コピー済み
コピー
コピー済み
+
if (
\Drupal::service('url_embed')->
getEmbed
(Html::decodeEntities($match[1]))
) {
+
try {
return '<drupal-url data-embed-url="' . $match[1] . '"></drupal-url>';
+ $info =
\Drupal::service('url_embed')->
getUrlInfo
(Html::decodeEntities($match[1]))
;
}
+ if ($info
) {
else {
+
return '<drupal-url data-embed-url="' . $match[1] . '"></drupal-url>';
+
}
+
else {
+ return $match[1];
+ }
+ } catch (\Exception $e) {
+ // If anything goes wrong while retrieving remote data, catch
+ // the exception to avoid a WSOD and leave the URL as is.
+ watchdog_exception('url_embed', $e);
return $match[1];
return $match[1];
}
}
- } catch (\Exception $e) {
- } catch (\Exception $e) {
- // If anything goes wrong while retrieving remote data, catch
- // If anything goes wrong while retrieving remote data, catch
- // the exception to avoid a WSOD and leave the URL as is.
- // the exception to avoid a WSOD and leave the URL as is.
- watchdog_exception('url_embed', $e);
- watchdog_exception('url_embed', $e);
- return $match[1];
- return $match[1];
- }
- }
- },
- },
- $chunks[$i]
- $chunks[$i]
- );
- );
- }
- }
- // Text chunk is done, so next chunk must be a tag.
- // Text chunk is done, so next chunk must be a tag.
- $chunk_type = 'tag';
- $chunk_type = 'tag';
- }
- }
- else {
- else {
- // Only process this tag if there are no unclosed $ignore_tags.
- // Only process this tag if there are no unclosed $ignore_tags.
- if ($open_tag == '') {
- if ($open_tag == '') {
- // Check whether this tag is contained in $ignore_tags.
- // Check whether this tag is contained in $ignore_tags.
- if (preg_match("`<($ignore_tags)(?:\s|>)`i", $chunks[$i], $matches)) {
- if (preg_match("`<($ignore_tags)(?:\s|>)`i", $chunks[$i], $matches)) {
- $open_tag = $matches[1];
- $open_tag = $matches[1];
+ },
+ },
+ $chunks[$i]
+ $chunks[$i]
+ );
+ );
}
}
+ // Text chunk is done, so next chunk must be a tag.
+ // Text chunk is done, so next chunk must be a tag.
+ $chunk_type = 'tag';
+ $chunk_type = 'tag';
}
}
- // Otherwise, check whether this is the closing tag for $open_tag.
- // Otherwise, check whether this is the closing tag for $open_tag.
else {
else {
- if (preg_match("`<\/$open_tag>`i", $chunks[$i], $matches)) {
- if (preg_match("`<\/$open_tag>`i", $chunks[$i], $matches)) {
- $open_tag = '';
- $open_tag = '';
+ // Only process this tag if there are no unclosed $ignore_tags.
+ // Only process this tag if there are no unclosed $ignore_tags.
+ if ($open_tag == '') {
+ if ($open_tag == '') {
+ // Check whether this tag is contained in $ignore_tags.
+ // Check whether this tag is contained in $ignore_tags.
+ if (preg_match("`<($ignore_tags)(?:\s|>)`i", $chunks[$i], $matches)) {
+ if (preg_match("`<($ignore_tags)(?:\s|>)`i", $chunks[$i], $matches)) {
+ $open_tag = $matches[1];
+ $open_tag = $matches[1];
+ }
+ }
}
}
+ // Otherwise, check whether this is the closing tag for $open_tag.
+ // Otherwise, check whether this is the closing tag for $open_tag.
+ else {
+ else {
+ if (preg_match("`<\/$open_tag>`i", $chunks[$i], $matches)) {
+ if (preg_match("`<\/$open_tag>`i", $chunks[$i], $matches)) {
+ $open_tag = '';
+ $open_tag = '';
+ }
+ }
+ }
+ }
+ // Tag chunk is done, so next chunk must be text.
+ // Tag chunk is done, so next chunk must be text.
+ $chunk_type = 'text';
+ $chunk_type = 'text';
}
}
- // Tag chunk is done, so next chunk must be text.
- // Tag chunk is done, so next chunk must be text.
- $chunk_type = 'text';
- $chunk_type = 'text';
}
}
+
+
+ $text = implode($chunks);
+ $text = implode($chunks);
}
}
- $text = implode($chunks);
- $text = implode($chunks);
// Revert to the original comment contents
// Revert to the original comment contents
_filter_url_escape_comments('', FALSE);
_filter_url_escape_comments('', FALSE);
return preg_replace_callback('`<!--(.*?)-->`', '_filter_url_escape_comments', $text);
return preg_replace_callback('`<!--(.*?)-->`', '_filter_url_escape_comments', $text);
保存された差分
原文
ファイルを開く
diff --git a/src/Plugin/Filter/ConvertUrlToEmbedFilter.php b/src/Plugin/Filter/ConvertUrlToEmbedFilter.php index d164700..267e636 100644 --- a/src/Plugin/Filter/ConvertUrlToEmbedFilter.php +++ b/src/Plugin/Filter/ConvertUrlToEmbedFilter.php @@ -116,69 +116,65 @@ class ConvertUrlToEmbedFilter extends FilterBase { // markup, especially a '>'. Therefore, remove all comment contents and add // them back later. _filter_url_escape_comments('', TRUE); - $text = preg_replace_callback('`<!--(.*?)-->`s', '_filter_url_escape_comments', $text); + $text = is_null($text) ? '' : preg_replace_callback('`<!--(.*?)-->`s', '_filter_url_escape_comments', $text); // Split at all tags; ensures that no tags or attributes are processed. - $chunks = preg_split('/(<.+?>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE); - // PHP ensures that the array consists of alternating delimiters and - // literals, and begins and ends with a literal (inserting NULL as - // required). Therefore, the first chunk is always text: - $chunk_type = 'text'; - // If a tag of $ignore_tags is found, it is stored in $open_tag and only - // removed when the closing tag is found. Until the closing tag is found, - // no replacements are made. - $open_tag = ''; - - for ($i = 0; $i < count($chunks); $i++) { - if ($chunk_type == 'text') { - // Only process this text if there are no unclosed $ignore_tags. - if ($open_tag == '') { - // If there is a match, inject a link into this chunk via the callback - // function contained in $task. - $chunks[$i] = preg_replace_callback( - $pattern, - function ($match) { - try { - $info = \Drupal::service('url_embed')->getUrlInfo(Html::decodeEntities($match[1])); - if ($info) { + $chunks = is_null($text) ? [''] : preg_split('/(<.+?>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE); + + // Do not attempt to convert links into URLs if preg_split() fails. + if ($chunks !== FALSE) { + // PHP ensures that the array consists of alternating delimiters and + // literals, and begins and ends with a literal (inserting NULL as + // required). Therefore, the first chunk is always text: + $chunk_type = 'text'; + // If a tag of $ignore_tags is found, it is stored in $open_tag and only + // removed when the closing tag is found. Until the closing tag is found, + // no replacements are made. + $open_tag = ''; + for ($i = 0; $i < count($chunks); $i++) { + if ($chunk_type == 'text') { + // Only process this text if there are no unclosed $ignore_tags. + if ($open_tag == '') { + // If there is a match, inject a link into this chunk via the callback + // function contained in $task. + $chunks[$i] = preg_replace_callback( + $pattern, + function ($match) { + if (\Drupal::service('url_embed')->getEmbed(Html::decodeEntities($match[1]))) { return '<drupal-url data-embed-url="' . $match[1] . '"></drupal-url>'; } else { return $match[1]; } - } catch (\Exception $e) { - // If anything goes wrong while retrieving remote data, catch - // the exception to avoid a WSOD and leave the URL as is. - watchdog_exception('url_embed', $e); - return $match[1]; - } - }, - $chunks[$i] - ); - } - // Text chunk is done, so next chunk must be a tag. - $chunk_type = 'tag'; - } - else { - // Only process this tag if there are no unclosed $ignore_tags. - if ($open_tag == '') { - // Check whether this tag is contained in $ignore_tags. - if (preg_match("`<($ignore_tags)(?:\s|>)`i", $chunks[$i], $matches)) { - $open_tag = $matches[1]; + }, + $chunks[$i] + ); } + // Text chunk is done, so next chunk must be a tag. + $chunk_type = 'tag'; } - // Otherwise, check whether this is the closing tag for $open_tag. else { - if (preg_match("`<\/$open_tag>`i", $chunks[$i], $matches)) { - $open_tag = ''; + // Only process this tag if there are no unclosed $ignore_tags. + if ($open_tag == '') { + // Check whether this tag is contained in $ignore_tags. + if (preg_match("`<($ignore_tags)(?:\s|>)`i", $chunks[$i], $matches)) { + $open_tag = $matches[1]; + } } + // Otherwise, check whether this is the closing tag for $open_tag. + else { + if (preg_match("`<\/$open_tag>`i", $chunks[$i], $matches)) { + $open_tag = ''; + } + } + // Tag chunk is done, so next chunk must be text. + $chunk_type = 'text'; } - // Tag chunk is done, so next chunk must be text. - $chunk_type = 'text'; } + + $text = implode($chunks); } - $text = implode($chunks); // Revert to the original comment contents _filter_url_escape_comments('', FALSE); return preg_replace_callback('`<!--(.*?)-->`', '_filter_url_escape_comments', $text);
変更されたテキスト
ファイルを開く
diff --git a/src/Plugin/Filter/ConvertUrlToEmbedFilter.php b/src/Plugin/Filter/ConvertUrlToEmbedFilter.php index d164700..a77c573 100644 --- a/src/Plugin/Filter/ConvertUrlToEmbedFilter.php +++ b/src/Plugin/Filter/ConvertUrlToEmbedFilter.php @@ -116,69 +116,73 @@ class ConvertUrlToEmbedFilter extends FilterBase { // markup, especially a '>'. Therefore, remove all comment contents and add // them back later. _filter_url_escape_comments('', TRUE); - $text = preg_replace_callback('`<!--(.*?)-->`s', '_filter_url_escape_comments', $text); + $text = is_null($text) ? '' : preg_replace_callback('`<!--(.*?)-->`s', '_filter_url_escape_comments', $text); // Split at all tags; ensures that no tags or attributes are processed. - $chunks = preg_split('/(<.+?>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE); - // PHP ensures that the array consists of alternating delimiters and - // literals, and begins and ends with a literal (inserting NULL as - // required). Therefore, the first chunk is always text: - $chunk_type = 'text'; - // If a tag of $ignore_tags is found, it is stored in $open_tag and only - // removed when the closing tag is found. Until the closing tag is found, - // no replacements are made. - $open_tag = ''; - - for ($i = 0; $i < count($chunks); $i++) { - if ($chunk_type == 'text') { - // Only process this text if there are no unclosed $ignore_tags. - if ($open_tag == '') { - // If there is a match, inject a link into this chunk via the callback - // function contained in $task. - $chunks[$i] = preg_replace_callback( - $pattern, - function ($match) { - try { - $info = \Drupal::service('url_embed')->getUrlInfo(Html::decodeEntities($match[1])); - if ($info) { - return '<drupal-url data-embed-url="' . $match[1] . '"></drupal-url>'; - } - else { + $chunks = is_null($text) ? [''] : preg_split('/(<.+?>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE); + + // Do not attempt to convert links into URLs if preg_split() fails. + if ($chunks !== FALSE) { + // PHP ensures that the array consists of alternating delimiters and + // literals, and begins and ends with a literal (inserting NULL as + // required). Therefore, the first chunk is always text: + $chunk_type = 'text'; + // If a tag of $ignore_tags is found, it is stored in $open_tag and only + // removed when the closing tag is found. Until the closing tag is found, + // no replacements are made. + $open_tag = ''; + for ($i = 0; $i < count($chunks); $i++) { + if ($chunk_type == 'text') { + // Only process this text if there are no unclosed $ignore_tags. + if ($open_tag == '') { + // If there is a match, inject a link into this chunk via the callback + // function contained in $task. + $chunks[$i] = preg_replace_callback( + $pattern, + function ($match) { + try { + $info = \Drupal::service('url_embed')->getUrlInfo(Html::decodeEntities($match[1])); + if ($info) { + return '<drupal-url data-embed-url="' . $match[1] . '"></drupal-url>'; + } + else { + return $match[1]; + } + } catch (\Exception $e) { + // If anything goes wrong while retrieving remote data, catch + // the exception to avoid a WSOD and leave the URL as is. + watchdog_exception('url_embed', $e); return $match[1]; } - } catch (\Exception $e) { - // If anything goes wrong while retrieving remote data, catch - // the exception to avoid a WSOD and leave the URL as is. - watchdog_exception('url_embed', $e); - return $match[1]; - } - }, - $chunks[$i] - ); - } - // Text chunk is done, so next chunk must be a tag. - $chunk_type = 'tag'; - } - else { - // Only process this tag if there are no unclosed $ignore_tags. - if ($open_tag == '') { - // Check whether this tag is contained in $ignore_tags. - if (preg_match("`<($ignore_tags)(?:\s|>)`i", $chunks[$i], $matches)) { - $open_tag = $matches[1]; + }, + $chunks[$i] + ); } + // Text chunk is done, so next chunk must be a tag. + $chunk_type = 'tag'; } - // Otherwise, check whether this is the closing tag for $open_tag. else { - if (preg_match("`<\/$open_tag>`i", $chunks[$i], $matches)) { - $open_tag = ''; + // Only process this tag if there are no unclosed $ignore_tags. + if ($open_tag == '') { + // Check whether this tag is contained in $ignore_tags. + if (preg_match("`<($ignore_tags)(?:\s|>)`i", $chunks[$i], $matches)) { + $open_tag = $matches[1]; + } } + // Otherwise, check whether this is the closing tag for $open_tag. + else { + if (preg_match("`<\/$open_tag>`i", $chunks[$i], $matches)) { + $open_tag = ''; + } + } + // Tag chunk is done, so next chunk must be text. + $chunk_type = 'text'; } - // Tag chunk is done, so next chunk must be text. - $chunk_type = 'text'; } + + $text = implode($chunks); } - $text = implode($chunks); // Revert to the original comment contents _filter_url_escape_comments('', FALSE); return preg_replace_callback('`<!--(.*?)-->`', '_filter_url_escape_comments', $text);
違いを見つける