Diff
checker
텍스트
텍스트
이미지
문서
Excel
폴더
Legal
Enterprise
데스크톱
요금제
로그인
데스크톱 앱 다운로드
텍스트 비교
두 텍스트 파일의 차이점을 찾아보세요
도구
기록
실시간 편집
변경 없는 행 숨기기
줄바꿈 비활성화
레이아웃
나란히 보기
합쳐 보기
비교 단위
스마트
단어
글자
구문 강조
언어 선택
제외
텍스트 변환
첫 변경으로
수정
Diffchecker Desktop
가장 안전하게 Diffchecker를 사용하는 방법. 데스크톱 앱을 사용하면 비교 데이터가 외부로 전송되지 않습니다!
데스크톱 앱 받기
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);
비교하기