diff --git a/js/privatebin.js b/js/privatebin.js
index 8b98ba8..e5067f4 100644
--- a/js/privatebin.js
+++ b/js/privatebin.js
@@ -164,13 +164,13 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
var markup = '$1';
element.html(
element.html().replace(
- /((http|https|ftp):\/\/[\w?=&.\/-;#@~%+-]+(?![\w\s?&.\/;#~%"=-]*>))/ig,
+ /((http|https|ftp):\/\/[\w?=&.\/-;#@~%+*-]+(?![\w\s?&.\/;#~%"=-]*>))/ig,
markup
)
);
element.html(
element.html().replace(
- /((magnet):[\w?=&.\/-;#@~%+-]+)/ig,
+ /((magnet):[\w?=&.\/-;#@~%+*-]+)/ig,
markup
)
);
diff --git a/js/test.js b/js/test.js
index 7906743..09ba881 100644
--- a/js/test.js
+++ b/js/test.js
@@ -165,6 +165,64 @@ describe('helper', function () {
);
});
+ describe('urls2links', function () {
+ jsc.property(
+ 'ignores non-URL content',
+ 'string',
+ function (content) {
+ var element = $('
' + content + '
'),
+ before = element.html();
+ $.PrivateBin.helper.urls2links(element);
+ return before === element.html();
+ }
+ );
+ jsc.property(
+ 'replaces URLs with anchors',
+ 'string',
+ jsc.elements(['http', 'https', 'ftp']),
+ jsc.nearray(jsc.elements(a2zString)),
+ jsc.array(jsc.elements(queryString)),
+ jsc.array(jsc.elements(queryString)),
+ 'string',
+ function (prefix, schema, address, query, fragment, postfix) {
+ var query = query.join(''),
+ fragment = fragment.join(''),
+ url = schema + '://' + address.join('') + '/?' + query + '#' + fragment,
+ prefix = $.PrivateBin.helper.htmlEntities(prefix),
+ postfix = ' ' + $.PrivateBin.helper.htmlEntities(postfix),
+ element = $('' + prefix + url + postfix + '
');
+
+ // special cases: When the query string and fragment imply the beginning of an HTML entity, eg. or
+ if (
+ query.slice(-1) === '&' &&
+ (parseInt(fragment.substring(0, 1), 10) >= 0 || fragment.charAt(0) === 'x' )
+ )
+ {
+ url = schema + '://' + address.join('') + '/?' + query.substring(0, query.length - 1);
+ postfix = '';
+ element = $('' + prefix + url + '
');
+ }
+
+ $.PrivateBin.helper.urls2links(element);
+ return element.html() === $('').html();
+ }
+ );
+ jsc.property(
+ 'replaces magnet links with anchors',
+ 'string',
+ jsc.array(jsc.elements(queryString)),
+ 'string',
+ function (prefix, query, postfix) {
+ var url = 'magnet:?' + query.join(''),
+ prefix = $.PrivateBin.helper.htmlEntities(prefix),
+ postfix = $.PrivateBin.helper.htmlEntities(postfix),
+ element = $('' + prefix + url + ' ' + postfix + '
');
+ $.PrivateBin.helper.urls2links(element);
+ return element.html() === $('').html();
+ }
+ );
+ });
+
describe('scriptLocation', function () {
jsc.property(
'returns the URL without query & fragment',
diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php
index 50f203b..15f83e0 100644
--- a/tpl/bootstrap.php
+++ b/tpl/bootstrap.php
@@ -69,7 +69,7 @@ if ($MARKDOWN):
-
+
diff --git a/tpl/page.php b/tpl/page.php
index 88af3aa..ccfeacb 100644
--- a/tpl/page.php
+++ b/tpl/page.php
@@ -47,7 +47,7 @@ if ($MARKDOWN):
-
+