Bug 371109 - Sending URL-encoded links when outgoing color codes are enabled should not break.

r=silver@warwickcompsoc.co.uk (James Ross)
p=mook.moz+mozbz@gmail.com (Mook)
ChatZilla Only.
This commit is contained in:
gijskruitbosch%gmail.com 2007-03-01 19:32:27 +00:00
Родитель 170b6604cd
Коммит 525079d623
2 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -57,7 +57,7 @@ function initMunger()
* - end with whitespace, non-word, or end-of-line
*/
client.linkRE =
/(?:\s|\W|^)((?:(\w[\w-]+):[^\s]+|www(\.[^.\s]+){2,})\b[\/=]?)(?:\s|\W|$)/;
/(?:\s|\W|^)((?:(\w[\w-]+):[^\s]+|www(\.[^.\s]+){2,})\b[\/=]?)(?=\s|\W|$)/;
const LOW_PRIORITY = 5;
const NORMAL_PRIORITY = 10;

Просмотреть файл

@ -2665,6 +2665,16 @@ function getFrameForDOMWindow(window)
function replaceColorCodes(msg)
{
// find things that look like URLs and escape the color code inside of those to
// prevent munging the URLs resulting in broken links
msg = msg.replace(new RegExp(client.linkRE.source, "g"), function(url) {
return url.replace(/%[BC][0-9A-Fa-f]/g, function(hex, index) {
// as JS does not support lookbehind and we don't want to consume the
// preceding character, we test for an existing %% manually
return (("%" == url.substr(index - 1, 1)) ? "" : "%") + hex;
});
});
// mIRC codes: underline, bold, Original (reset), colors, reverse colors.
msg = msg.replace(/(^|[^%])%U/g, "$1\x1f");
msg = msg.replace(/(^|[^%])%B/g, "$1\x02");