Apply sentinel fixes to _StripLinkDefinitions

This commit is contained in:
Adam Backstrom 2012-10-19 11:55:49 -04:00
parent 3b9b743f90
commit 6645ca173b

View File

@ -184,7 +184,11 @@ var _StripLinkDefinitions = function(text) {
/gm, /gm,
function(){...}); function(){...});
*/ */
var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,
// attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
text += "~0";
var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|(?=~0))/gm,
function (wholeMatch,m1,m2,m3,m4) { function (wholeMatch,m1,m2,m3,m4) {
m1 = m1.toLowerCase(); m1 = m1.toLowerCase();
g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive
@ -201,6 +205,9 @@ var _StripLinkDefinitions = function(text) {
} }
); );
// attacklab: strip sentinel
text = text.replace(/~0/,"");
return text; return text;
} }