From 119c3931cc936aac2f45e0216a73f12a89d7b0d1 Mon Sep 17 00:00:00 2001 From: rugk Date: Sun, 1 Jul 2018 15:13:24 +0200 Subject: [PATCH] Try new RegEx for creating links --- js/privatebin.js | 3 ++- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 9c1e91e..f297d39 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -144,8 +144,9 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) { */ me.urls2links = function(html) { + // URL part of RegEx: https://regex101.com/r/h4ACei/4 return html.replace( - /(((http|https|ftp):\/\/[\w?=&.\/-;#@~%+*-]+(?![\w\s?&.\/;#~%"=-]*>))|((magnet):[\w?=&.\/-;#@~%+*-]+))/ig, + /((https?|ftp):\/\/(([a-z0-9$_\.\+!\*\'\(\),;\?&=-]|%[0-9a-f]{2})+(:([a-z0-9$_\.\+!\*\'\(\),;\?&=-]|%[0-9a-f]{2})+)?@)?((([a-z0-9]\.|[a-z0-9][a-z0-9-]*[a-z0-9]\.)*[a-z][a-z0-9-]*[a-z0-9]|((\d|[1-9]\d|1\d{2}|2[0-4][0-9]|25[0-5])\.){3}(\d|[1-9]\d|1\d{2}|2[0-4][0-9]|25[0-5]))(:\d+)?)(((\/+([a-z0-9$_\.\+!\*\'\(\),;:@&=-]|%[0-9a-f]{2})*)*(\?([a-z0-9$_\.\+!\*\'\(\),;:@&=-]|%[0-9a-f]{2})*)?)?)?(#([a-z0-9$_\.\+!\*\'\(\),;:@&=-]|%[0-9a-f]{2})*)?)|((magnet):[\w?=&.\/-;#@~%+*-]+)/ig, '$1' ); }; diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 2f27727..5aa45bf 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -75,7 +75,7 @@ if ($MARKDOWN): - + diff --git a/tpl/page.php b/tpl/page.php index acf0bdc..9954008 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -54,7 +54,7 @@ if ($QRCODE): - +