Skip to content

Commit

Permalink
fix media regex in page render
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-peugnet committed Nov 6, 2022
1 parent df8dd77 commit ad17efd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/class/Servicerender.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,13 @@ private function desctitle($text, $desc, $title)
* Add a target="_blank" attribute to link pointing to media.
*
* About the regex : it will match everything that do not start with a `./` a `/` or an URI sheme.
* (`https://`, `ftps://`, etc.) and contain at list one point `.`
* (`https:`, `ftps:`, `mailto:`, `matrix:` etc.) and contain at list one point `.`
*/
private function media(string $text): string
{
$regex = '%href="(?!([/#]|[a-zA-Z\.\-\+]+://|\.+/))([^"]+\.[^"]+)"%';
$regex = '%href="(?!([/#]|[a-zA-Z\.\-\+]+:|\.+/))([^"]+\.[^"]+)"%';
$text = preg_replace($regex, 'href="' . Model::mediapath() . '$2" target="_blank"', $text);
$regex = '%src="(?!([/#]|[a-zA-Z\.\-\+]+://|\.+/))([^"]+\.[^"]+)"%';
$regex = '%src="(?!([/#]|[a-zA-Z\.\-\+]+:|\.+/))([^"]+\.[^"]+)"%';
$text = preg_replace($regex, 'src="' . Model::mediapath() . '$2"', $text);
return $text;
}
Expand Down

0 comments on commit ad17efd

Please sign in to comment.