Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Commit c503d17

Browse files
author
Zirak
committed
i r retard
1 parent 4fd2420 commit c503d17

File tree

4 files changed

+180
-174
lines changed

4 files changed

+180
-174
lines changed

master.js

Lines changed: 85 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ setTimeout(function () {
12591259
return;
12601260
}
12611261

1262-
IO.injectScript( 'https://raw.github.com/jashkenas/coffee-script/master/extras/coffee-script.js' );
1262+
IO.injectScript( 'https://rawgithub.com/jashkenas/coffee-script/master/extras/coffee-script.js' );
12631263
}, 1000);
12641264

12651265
//execute arbitrary js code in a relatively safe environment
@@ -1493,7 +1493,7 @@ var blob = new Blob( [workerCode], { type : 'application/javascript' } ),
14931493
codeUrl = window.URL.createObjectURL( blob );
14941494

14951495
return function ( code, arg, cb ) {
1496-
if ( arguments.length === 2 ) {
1496+
if ( arguments.length === 2 ) {
14971497
cb = arg;
14981498
arg = null;
14991499
}
@@ -1502,7 +1502,7 @@ return function ( code, arg, cb ) {
15021502
timeout;
15031503

15041504
worker.onmessage = function ( evt ) {
1505-
bot.log( evt, 'eval worker.onmessage' );
1505+
bot.log( evt, 'eval worker.onmessage' );
15061506

15071507
var type = evt.data.event;
15081508

@@ -1566,48 +1566,48 @@ bot.prettyEval = function ( code, arg, cb ) {
15661566

15671567
return bot.eval( code, arg, finish );
15681568

1569-
function finish ( err, answerObj ) {
1570-
if ( err ) {
1571-
cb( err );
1572-
}
1573-
else {
1574-
cb( dressUpAnswer(answerObj) );
1575-
}
1576-
}
1569+
function finish ( err, answerObj ) {
1570+
if ( err ) {
1571+
cb( err );
1572+
}
1573+
else {
1574+
cb( dressUpAnswer(answerObj) );
1575+
}
1576+
}
15771577

1578-
function dressUpAnswer ( answerObj ) {
1579-
bot.log( answerObj, 'eval answerObj' );
1580-
var answer = answerObj.answer,
1581-
log = answerObj.log,
1582-
result;
1578+
function dressUpAnswer ( answerObj ) {
1579+
bot.log( answerObj, 'eval answerObj' );
1580+
var answer = answerObj.answer,
1581+
log = answerObj.log,
1582+
result;
15831583

1584-
if ( answer === undefined ) {
1585-
return 'Malformed output from web-worker. If you weren\'t just ' +
1586-
'fooling around trying to break me, raise an issue or contact ' +
1587-
'Zirak';
1588-
}
1584+
if ( answer === undefined ) {
1585+
return 'Malformed output from web-worker. If you weren\'t just ' +
1586+
'fooling around trying to break me, raise an issue or contact ' +
1587+
'Zirak';
1588+
}
15891589

1590-
result = snipAndCodify( answer );
1590+
result = snipAndCodify( answer );
15911591

1592-
if ( log && log.length ) {
1593-
result += ' Logged: ' + snipAndCodify( log );
1594-
}
1592+
if ( log && log.length ) {
1593+
result += ' Logged: ' + snipAndCodify( log );
1594+
}
15951595

1596-
return result;
1597-
}
1596+
return result;
1597+
}
15981598

1599-
function snipAndCodify ( str ) {
1600-
var ret;
1599+
function snipAndCodify ( str ) {
1600+
var ret;
16011601

1602-
if ( str.length > 400 ) {
1603-
ret = '`' + str.slice(0, 400) + '` (snip)';
1604-
}
1605-
else {
1606-
ret = '`' + str +'`';
1607-
}
1602+
if ( str.length > 400 ) {
1603+
ret = '`' + str.slice(0, 400) + '` (snip)';
1604+
}
1605+
else {
1606+
ret = '`' + str +'`';
1607+
}
16081608

1609-
return ret;
1610-
}
1609+
return ret;
1610+
}
16111611
};
16121612

16131613

@@ -5757,24 +5757,26 @@ function substitute ( msg ) {
57575757
var messages;
57585758
if ( msg.matches[5] ) {
57595759
messages = Array.from(
5760-
document.querySelectorAll('#message-' + msg.matches[5] + ' .content') );
5760+
document.querySelectorAll('#message-' + msg.matches[5] + ' .content')
5761+
);
57615762
}
57625763
else {
57635764
messages = Array.from(
5764-
document.getElementsByClassName('content') ).reverse();
5765+
document.getElementsByClassName('content')
5766+
).reverse();
57655767
}
57665768

57675769
getMatchingMessage( re, messages, msg.get('message_id'), function ( err, message ) {
5768-
if ( err ) {
5769-
msg.reply( err );
5770-
return;
5771-
}
5770+
if ( err ) {
5771+
msg.reply( err );
5772+
return;
5773+
}
57725774

57735775
if ( !message ) {
57745776
msg.reply(
57755777
'No matching message (are you sure we\'re in the right room?)'
57765778
);
5777-
return;
5779+
return;
57785780
}
57795781
bot.log( message, 'substitution found message' );
57805782

@@ -5798,58 +5800,59 @@ function substitute ( msg ) {
57985800
}
57995801

58005802
function getMatchingMessage ( re, messages, onlyBefore, cb ) {
5801-
var arg = {
5802-
maxId : onlyBefore,
5803-
pattern : re,
5804-
messages : messages.map(function ( el ) {
5805-
return {
5806-
id : Number( el.parentElement.id.match(/\d+/)[0] ),
5807-
text : el.textContent
5808-
};
5809-
})
5810-
};
5811-
5812-
// the following function is passed to bot.eval, which means it will run in
5813-
//a different context. the only variable we get is ~arg~, because we pass it
5814-
//to bot.eval
5815-
// we do the skip and jump through bot.eval to avoid a ReDoS (#217).
5816-
var matcher = function () {
5803+
bot.log( re, messages, onlyBefore, 'substitution getMatchingMessage args' );
5804+
var arg = {
5805+
maxId : onlyBefore,
5806+
pattern : re,
5807+
messages : messages.map(function ( el ) {
5808+
return {
5809+
id : Number( el.parentElement.id.match(/\d+/)[0] ),
5810+
text : el.textContent
5811+
};
5812+
})
5813+
};
5814+
5815+
// the following function is passed to bot.eval, which means it will run in
5816+
//a different context. the only variable we get is ~arg~, because we pass it
5817+
//to bot.eval
5818+
// we do the skip and jump through bot.eval to avoid a ReDoS (#217).
5819+
var matcher = function () {
58175820
var arg = arguments[1],
58185821
matchIndex = null;
58195822

5820-
arg.messages.some(function ( msg, idx ) {
5821-
if ( msg.id < arg.maxId && arg.pattern.test(msg.text) ) {
5822-
matchIndex = idx;
5823-
return true;
5824-
}
5823+
arg.messages.some(function ( msg, idx ) {
5824+
if ( msg.id < arg.maxId && arg.pattern.test(msg.text) ) {
5825+
matchIndex = idx;
5826+
return true;
5827+
}
58255828

5826-
return false;
5827-
});
5829+
return false;
5830+
});
58285831

5829-
// remember we're inside bot.eval, final expression is the result.
5832+
// remember we're inside bot.eval, final expression is the result.
58305833
// so it'll work well with minification, we have to create an expression
58315834
//which won't be removed
58325835
(function () {
58335836
return matchIndex;
58345837
})();
5835-
};
5838+
};
58365839

58375840
bot.eval( matcher.stringContents(), arg, function ( err, resp ) {
58385841
bot.log( err, resp, 'substitution matcher response' );
58395842

5840-
// meh
5841-
if ( err ) {
5842-
cb( err );
5843-
return;
5844-
}
5843+
// meh
5844+
if ( err ) {
5845+
cb( err );
5846+
return;
5847+
}
58455848

5846-
var index = JSON.parse( resp.answer );
5847-
if ( Number(index) !== index ) {
5848-
return;
5849-
}
5849+
var index = JSON.parse( resp.answer );
5850+
if ( Number(index) !== index ) {
5851+
return;
5852+
}
58505853

5851-
cb( null, messages[index] );
5852-
});
5854+
cb( null, messages[index] );
5855+
});
58535856
}
58545857

58555858
// <a class="action-link" href="/transcript/message/msgid#msgid>...</a>
@@ -5867,8 +5870,8 @@ function getMessageLink ( message ) {
58675870
}
58685871

58695872
// <div class="content">
5870-
// <div class="partial"> ... </div>
5871-
// <a class="more-data" href="what we want">(see full text)</a>
5873+
// <div class="partial"> ... </div>
5874+
// <a class="more-data" href="what we want">(see full text)</a>
58725875
// </div>
58735876
function retrieveFullText ( message, cb ) {
58745877
var href = message.children[ 1 ].href;

master.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

source/eval.js

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var blob = new Blob( [workerCode], { type : 'application/javascript' } ),
1818
codeUrl = window.URL.createObjectURL( blob );
1919

2020
return function ( code, arg, cb ) {
21-
if ( arguments.length === 2 ) {
21+
if ( arguments.length === 2 ) {
2222
cb = arg;
2323
arg = null;
2424
}
@@ -27,7 +27,7 @@ return function ( code, arg, cb ) {
2727
timeout;
2828

2929
worker.onmessage = function ( evt ) {
30-
bot.log( evt, 'eval worker.onmessage' );
30+
bot.log( evt, 'eval worker.onmessage' );
3131

3232
var type = evt.data.event;
3333

@@ -91,46 +91,46 @@ bot.prettyEval = function ( code, arg, cb ) {
9191

9292
return bot.eval( code, arg, finish );
9393

94-
function finish ( err, answerObj ) {
95-
if ( err ) {
96-
cb( err );
97-
}
98-
else {
99-
cb( dressUpAnswer(answerObj) );
100-
}
101-
}
102-
103-
function dressUpAnswer ( answerObj ) {
104-
bot.log( answerObj, 'eval answerObj' );
105-
var answer = answerObj.answer,
106-
log = answerObj.log,
107-
result;
108-
109-
if ( answer === undefined ) {
110-
return 'Malformed output from web-worker. If you weren\'t just ' +
111-
'fooling around trying to break me, raise an issue or contact ' +
112-
'Zirak';
113-
}
114-
115-
result = snipAndCodify( answer );
116-
117-
if ( log && log.length ) {
118-
result += ' Logged: ' + snipAndCodify( log );
119-
}
120-
121-
return result;
122-
}
123-
124-
function snipAndCodify ( str ) {
125-
var ret;
126-
127-
if ( str.length > 400 ) {
128-
ret = '`' + str.slice(0, 400) + '` (snip)';
129-
}
130-
else {
131-
ret = '`' + str +'`';
132-
}
133-
134-
return ret;
135-
}
94+
function finish ( err, answerObj ) {
95+
if ( err ) {
96+
cb( err );
97+
}
98+
else {
99+
cb( dressUpAnswer(answerObj) );
100+
}
101+
}
102+
103+
function dressUpAnswer ( answerObj ) {
104+
bot.log( answerObj, 'eval answerObj' );
105+
var answer = answerObj.answer,
106+
log = answerObj.log,
107+
result;
108+
109+
if ( answer === undefined ) {
110+
return 'Malformed output from web-worker. If you weren\'t just ' +
111+
'fooling around trying to break me, raise an issue or contact ' +
112+
'Zirak';
113+
}
114+
115+
result = snipAndCodify( answer );
116+
117+
if ( log && log.length ) {
118+
result += ' Logged: ' + snipAndCodify( log );
119+
}
120+
121+
return result;
122+
}
123+
124+
function snipAndCodify ( str ) {
125+
var ret;
126+
127+
if ( str.length > 400 ) {
128+
ret = '`' + str.slice(0, 400) + '` (snip)';
129+
}
130+
else {
131+
ret = '`' + str +'`';
132+
}
133+
134+
return ret;
135+
}
136136
};

0 commit comments

Comments
 (0)