mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-12-22 11:30:20 +00:00
Merge pull request #930 from annando/markdown-encoding
Markdown: Protect some more elements from markdown parsing
This commit is contained in:
commit
aa7f8e7bdf
1 changed files with 7 additions and 7 deletions
|
@ -50,11 +50,11 @@ function markdown_post_local_start(App $a, &$request) {
|
|||
}
|
||||
|
||||
// Elements that shouldn't be parsed
|
||||
$elements = ['code', 'noparse', 'nobb', 'pre'];
|
||||
$elements = ['code', 'noparse', 'nobb', 'pre', 'share', 'url', 'img'];
|
||||
foreach ($elements as $element) {
|
||||
$request['body'] = preg_replace_callback("/\[" . $element . "\](.*?)\[\/" . $element . "\]/ism",
|
||||
function ($match) use ($element) {
|
||||
return '[base64' . $element . ']' . base64_encode($match[1]) . '[/base64' . $element . ']';
|
||||
$request['body'] = preg_replace_callback("/\[" . $element . "(.*?)\](.*?)\[\/" . $element . "\]/ism",
|
||||
function ($match) use ($element) {
|
||||
return '[' . $element . '-b64' . base64_encode($match[1]) . ']' . base64_encode($match[2]) . '[/b64-' . $element . ']';
|
||||
},
|
||||
$request['body']
|
||||
);
|
||||
|
@ -63,9 +63,9 @@ function markdown_post_local_start(App $a, &$request) {
|
|||
$request['body'] = Markdown::toBBCode($request['body']);
|
||||
|
||||
foreach (array_reverse($elements) as $element) {
|
||||
$request['body'] = preg_replace_callback("/\[base64" . $element . "\](.*?)\[\/base64" . $element . "\]/ism",
|
||||
function ($match) use ($element) {
|
||||
return '[' . $element . ']' . base64_decode($match[1]) . '[/' . $element . ']';
|
||||
$request['body'] = preg_replace_callback("/\[" . $element . "-b64(.*?)\](.*?)\[\/b64-" . $element . "\]/ism",
|
||||
function ($match) use ($element) {
|
||||
return '[' . $element . base64_decode($match[1]) . ']' . base64_decode($match[2]) . '[/' . $element . ']';
|
||||
},
|
||||
$request['body']
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue