stop urls being encoded, not sure about other security implications here...

This commit is contained in:
John McLear 2013-02-10 19:21:27 +00:00
parent a378f48c00
commit a67a0950dd
1 changed files with 2 additions and 38 deletions

View File

@ -129,8 +129,6 @@ function getTXTFromAtext(pad, atext, authorColors)
var assem = Changeset.stringAssembler(); var assem = Changeset.stringAssembler();
var openTags = []; var openTags = [];
var urls = _findURLs(text);
var idx = 0; var idx = 0;
function processNextChars(numChars) function processNextChars(numChars)
@ -239,7 +237,8 @@ function getTXTFromAtext(pad, atext, authorColors)
//from but they break the abiword parser and are completly useless //from but they break the abiword parser and are completly useless
s = s.replace(String.fromCharCode(12), ""); s = s.replace(String.fromCharCode(12), "");
assem.append(_encodeWhitespace(Security.escapeHTML(s))); // assem.append(_encodeWhitespace(Security.escapeHTML(s)));
assem.append(_encodeWhitespace(s));
} // end iteration over spans in line } // end iteration over spans in line
var tags2close = []; var tags2close = [];
@ -253,20 +252,6 @@ function getTXTFromAtext(pad, atext, authorColors)
} }
} // end processNextChars } // end processNextChars
if (urls)
{
urls.forEach(function (urlData)
{
var startIndex = urlData[0];
var url = urlData[1];
var urlLength = url.length;
processNextChars(startIndex - idx);
// assem.append('<a href="' + Security.escapeHTMLAttribute(url) + '">');
assem.append(url);
processNextChars(urlLength);
// assem.append('</a>');
});
}
processNextChars(text.length - idx); processNextChars(text.length - idx);
return _processSpaces(assem.toString()); return _processSpaces(assem.toString());
@ -452,24 +437,3 @@ function _processSpaces(s)
// copied from ACE // copied from ACE
var _REGEX_WORDCHAR = /[\u0030-\u0039\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u1FFF\u3040-\u9FFF\uF900-\uFDFF\uFE70-\uFEFE\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFDC]/; var _REGEX_WORDCHAR = /[\u0030-\u0039\u0041-\u005A\u0061-\u007A\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF\u0100-\u1FFF\u3040-\u9FFF\uF900-\uFDFF\uFE70-\uFEFE\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFDC]/;
var _REGEX_SPACE = /\s/; var _REGEX_SPACE = /\s/;
var _REGEX_URLCHAR = new RegExp('(' + /[-:@a-zA-Z0-9_.,~%+\/\\?=&#;()$]/.source + '|' + _REGEX_WORDCHAR.source + ')');
var _REGEX_URL = new RegExp(/(?:(?:https?|s?ftp|ftps|file|smb|afp|nfs|(x-)?man|gopher|txmt):\/\/|mailto:)/.source + _REGEX_URLCHAR.source + '*(?![:.,;])' + _REGEX_URLCHAR.source, 'g');
// returns null if no URLs, or [[startIndex1, url1], [startIndex2, url2], ...]
function _findURLs(text)
{
_REGEX_URL.lastIndex = 0;
var urls = null;
var execResult;
while ((execResult = _REGEX_URL.exec(text)))
{
urls = (urls || []);
var startIndex = execResult.index;
var url = execResult[0];
urls.push([startIndex, url]);
}
return urls;
}