Bug 190749 - Add a server-specific toLowerCase() to handle the CASEMAPPING. Update appropriate code to use it.
r=samuel@sieb.net git-svn-id: svn://10.0.0.236/trunk@153818 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
843ca20382
commit
f6cd33e8be
@ -322,6 +322,49 @@ CIRCServer.prototype.DEFAULT_REASON = "no reason";
|
||||
|
||||
CIRCServer.prototype.TYPE = "IRCServer";
|
||||
|
||||
CIRCServer.prototype.toLowerCase =
|
||||
function serv_tolowercase(str)
|
||||
{
|
||||
/* This is an implementation that lower-cases strings according to the
|
||||
* prevailing CASEMAPPING setting for the server. Values for this are:
|
||||
*
|
||||
* o "ascii": The ASCII characters 97 to 122 (decimal) are defined as
|
||||
* the lower-case characters of ASCII 65 to 90 (decimal). No other
|
||||
* character equivalency is defined.
|
||||
* o "strict-rfc1459": The ASCII characters 97 to 125 (decimal) are
|
||||
* defined as the lower-case characters of ASCII 65 to 93 (decimal).
|
||||
* No other character equivalency is defined.
|
||||
* o "rfc1459": The ASCII characters 97 to 126 (decimal) are defined as
|
||||
* the lower-case characters of ASCII 65 to 94 (decimal). No other
|
||||
* character equivalency is defined.
|
||||
*
|
||||
*/
|
||||
|
||||
function replaceFunction(chr)
|
||||
{
|
||||
return String.fromCharCode(chr.charCodeAt(0) + 32);
|
||||
}
|
||||
|
||||
var mapping = "rfc1459";
|
||||
if (this.supports)
|
||||
mapping = this.supports.casemapping;
|
||||
|
||||
/* NOTE: There are NO breaks in this switch. This is CORRECT.
|
||||
* Each mapping listed is a super-set of those below, thus we only
|
||||
* transform the extra characters, and then fall through.
|
||||
*/
|
||||
switch (mapping)
|
||||
{
|
||||
case "rfc1459":
|
||||
str = str.replace(/\^/g, replaceFunction);
|
||||
case "strict-rfc1459":
|
||||
str = str.replace(/[\[\\\]]/g, replaceFunction);
|
||||
case "ascii":
|
||||
str = str.replace(/[A-Z]/g, replaceFunction);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
CIRCServer.prototype.getURL =
|
||||
function serv_geturl(target)
|
||||
{
|
||||
@ -343,7 +386,7 @@ function serv_geturl(target)
|
||||
CIRCServer.prototype.getUser =
|
||||
function chan_getuser (nick)
|
||||
{
|
||||
nick = nick.toLowerCase();
|
||||
nick = this.toLowerCase(nick);
|
||||
|
||||
if (nick in this.users)
|
||||
return this.users[nick];
|
||||
@ -926,7 +969,7 @@ function serv_onRawData(e)
|
||||
CIRCServer.prototype.onParsedData =
|
||||
function serv_onParsedData(e)
|
||||
{
|
||||
e.type = e.code.toLowerCase();
|
||||
e.type = this.toLowerCase(e.code);
|
||||
if (!e.code[0])
|
||||
{
|
||||
dd (dumpObjectTree (e));
|
||||
@ -984,7 +1027,7 @@ function serv_001 (e)
|
||||
if (e.params[1] != e.server.me.properNick)
|
||||
{
|
||||
renameProperty (e.server.users, e.server.me.nick,
|
||||
e.params[1].toLowerCase());
|
||||
this.toLowerCase(e.params[1]));
|
||||
e.server.me.changeNick(e.params[1]);
|
||||
}
|
||||
|
||||
@ -1497,7 +1540,7 @@ CIRCServer.prototype.onNick =
|
||||
function serv_nick (e)
|
||||
{
|
||||
var newNick = e.params[1];
|
||||
var newKey = newNick.toLowerCase();
|
||||
var newKey = this.toLowerCase(newNick);
|
||||
var oldKey = e.user.nick;
|
||||
var ev;
|
||||
|
||||
@ -1924,7 +1967,7 @@ function serv_dccsend (e)
|
||||
|
||||
function CIRCChannel (parent, encodedName, unicodeName)
|
||||
{
|
||||
this.normalizedName = encodedName.toLowerCase();
|
||||
this.normalizedName = parent.toLowerCase(encodedName);
|
||||
this.name = this.normalizedName;
|
||||
|
||||
if (this.normalizedName in parent.channels)
|
||||
@ -1982,7 +2025,7 @@ function chan_adduser (nick, modes)
|
||||
CIRCChannel.prototype.getUser =
|
||||
function chan_getuser (nick)
|
||||
{
|
||||
nick = nick.toLowerCase();
|
||||
nick = this.parent.toLowerCase(nick);
|
||||
|
||||
if (nick in this.users)
|
||||
return this.users[nick];
|
||||
@ -1993,7 +2036,7 @@ function chan_getuser (nick)
|
||||
CIRCChannel.prototype.removeUser =
|
||||
function chan_removeuser (nick)
|
||||
{
|
||||
delete this.users[nick.toLowerCase()]; // see ya
|
||||
delete this.users[this.parent.toLowerCase(nick)]; // see ya
|
||||
}
|
||||
|
||||
CIRCChannel.prototype.getUsersLength =
|
||||
@ -2265,7 +2308,7 @@ function chan_secret (f)
|
||||
function CIRCUser (parent, nick, name, host)
|
||||
{
|
||||
var properNick = nick;
|
||||
nick = nick.toLowerCase();
|
||||
nick = parent.toLowerCase(nick);
|
||||
if (nick in parent.users)
|
||||
{
|
||||
var existingUser = parent.users[nick];
|
||||
@ -2303,7 +2346,7 @@ CIRCUser.prototype.changeNick =
|
||||
function usr_changenick (nick)
|
||||
{
|
||||
this.properNick = nick;
|
||||
this.nick = nick.toLowerCase();
|
||||
this.nick = this.parent.toLowerCase(nick);
|
||||
}
|
||||
|
||||
CIRCUser.prototype.getHostMask =
|
||||
@ -2356,7 +2399,7 @@ function usr_whois ()
|
||||
function CIRCChanUser (parent, nick, modes)
|
||||
{
|
||||
var properNick = nick;
|
||||
nick = nick.toLowerCase();
|
||||
nick = parent.parent.toLowerCase(nick);
|
||||
|
||||
if (nick in parent.users)
|
||||
{
|
||||
|
||||
@ -1540,7 +1540,7 @@ function cmdLeave(e)
|
||||
e.channelName = "#" + e.channelName;
|
||||
|
||||
e.channelName = fromUnicode(e.channelName, e.network);
|
||||
var key = e.channelName.toLowerCase();
|
||||
var key = e.server.toLowerCase(e.channelName);
|
||||
if (key in e.server.channels)
|
||||
e.channel = e.server.channels[key];
|
||||
else
|
||||
@ -1921,7 +1921,8 @@ function cmdInvite(e)
|
||||
}
|
||||
else
|
||||
{
|
||||
var encodeName = fromUnicode(e.channelName.toLowerCase(), e.network);
|
||||
var encodeName = fromUnicode(e.server.toLowerCase(e.channelName),
|
||||
e.network);
|
||||
channel = e.server.channels[encodeName];
|
||||
|
||||
if (!channel)
|
||||
@ -1998,7 +1999,7 @@ function cmdNotify(e)
|
||||
|
||||
for (var i in e.nicknameList)
|
||||
{
|
||||
var nickname = e.nicknameList[i].toLowerCase();
|
||||
var nickname = e.server.toLowerCase(e.nicknameList[i]);
|
||||
var idx = arrayIndexOf (net.prefs["notifyList"], nickname);
|
||||
if (idx == -1)
|
||||
{
|
||||
@ -2228,8 +2229,7 @@ function cmdIgnore(e)
|
||||
{
|
||||
if (("mask" in e) && e.mask)
|
||||
{
|
||||
// FIXME: This is incorrect if CASEMAPPING is not ASCII, see bug 190749.
|
||||
e.mask = e.mask.toLowerCase();
|
||||
e.mask = e.server.toLowerCase(e.mask);
|
||||
|
||||
if (e.command.name == "ignore")
|
||||
{
|
||||
|
||||
@ -350,9 +350,13 @@ function onTabCompleteRequest (e)
|
||||
if ("performTabMatch" in client.currentObject)
|
||||
{
|
||||
var word = line.substring (wordStart, wordEnd);
|
||||
var wordLower = word.toLowerCase();
|
||||
var d = getObjectDetails(client.currentObject);
|
||||
if (d.server)
|
||||
wordLower = d.server.toLowerCase(word);
|
||||
var matches = client.currentObject.performTabMatch (line, wordStart,
|
||||
wordEnd,
|
||||
word.toLowerCase(),
|
||||
wordLower,
|
||||
selStart);
|
||||
/* if we get null back, we're supposed to fail silently */
|
||||
if (!matches)
|
||||
@ -732,7 +736,7 @@ function my_303 (e)
|
||||
// split() gives an array of one item ("") when splitting "", which we
|
||||
// don't want, so only do the split if there's something to split.
|
||||
if (e.params[2])
|
||||
onList = stringTrim(e.params[2].toLowerCase()).split(/\s+/);
|
||||
onList = stringTrim(e.server.toLowerCase(e.params[2])).split(/\s+/);
|
||||
var offList = new Array();
|
||||
var newArrivals = new Array();
|
||||
var newDepartures = new Array();
|
||||
@ -896,7 +900,7 @@ function my_listrply (e)
|
||||
CIRCNetwork.prototype.on401 =
|
||||
function my_401 (e)
|
||||
{
|
||||
var target = e.params[2].toLowerCase();
|
||||
var target = e.server.toLowerCase(e.params[2]);
|
||||
if (target in this.users && "messages" in this.users[target])
|
||||
{
|
||||
this.users[target].displayHere(e.params[3]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user