mirror of
https://github.com/danog/telegram-entities.git
synced 2024-11-30 04:39:06 +01:00
Add entity escaping to URLs
This commit is contained in:
parent
d70207fdbb
commit
73dd84277d
@ -376,7 +376,7 @@ final class Entities
|
|||||||
'italic' => '<i>',
|
'italic' => '<i>',
|
||||||
'code' => '<code>',
|
'code' => '<code>',
|
||||||
'pre' => isset($entity['language']) && $entity['language'] !== '' ? '<pre language="'.$entity['language'].'">' : '<pre>',
|
'pre' => isset($entity['language']) && $entity['language'] !== '' ? '<pre language="'.$entity['language'].'">' : '<pre>',
|
||||||
'text_link' => '<a href="'.$entity['url'].'">',
|
'text_link' => '<a href="'.EntityTools::htmlEscape($entity['url']).'">',
|
||||||
'strikethrough' => '<s>',
|
'strikethrough' => '<s>',
|
||||||
"underline" => '<u>',
|
"underline" => '<u>',
|
||||||
"block_quote" => '<blockquote>',
|
"block_quote" => '<blockquote>',
|
||||||
|
@ -293,6 +293,18 @@ class EntitiesTest extends TestCase
|
|||||||
]]
|
]]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
yield [
|
||||||
|
'test',
|
||||||
|
'<a href="https://google.com/?arg=a&arg2=b">test</a>',
|
||||||
|
'<a href="https://google.com/?arg=a&arg2=b">test</a>',
|
||||||
|
[[
|
||||||
|
'type' => 'text_link',
|
||||||
|
'offset' => 0,
|
||||||
|
'length' => 4,
|
||||||
|
'url' => 'https://google.com/?arg=a&arg2=b',
|
||||||
|
]]
|
||||||
|
];
|
||||||
|
|
||||||
yield [
|
yield [
|
||||||
'test',
|
'test',
|
||||||
'<u>test</u>',
|
'<u>test</u>',
|
||||||
@ -787,17 +799,17 @@ class EntitiesTest extends TestCase
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
'html',
|
'html',
|
||||||
'<a href="https://google.com/">link </a>',
|
'<a href="https://google.com/?a=a&b=b">link </a>',
|
||||||
'link',
|
'link',
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
'offset' => 0,
|
'offset' => 0,
|
||||||
'length' => 4,
|
'length' => 4,
|
||||||
'type' => 'text_link',
|
'type' => 'text_link',
|
||||||
'url' => 'https://google.com/',
|
'url' => 'https://google.com/?a=a&b=b',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'<a href="https://google.com/">link</a> ',
|
'<a href="https://google.com/?a=a&b=b">link</a> ',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'markdown',
|
'markdown',
|
||||||
|
Loading…
Reference in New Issue
Block a user