File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,14 @@ module.exports = parseIrcLine;
99 */
1010var parse_regex = / ^ (?: @ ( [ ^ ] + ) ) ? (?: : ( (?: (?: ( [ ^ \s ! @ ] + ) (?: ! ( [ ^ \s @ ] + ) ) ? ) @ ) ? ( \S + ) ) ) ? ( (?: [ a - z A - Z ] + ) | (?: [ 0 - 9 ] { 3 } ) ) (?: ( [ ^ : ] .* ?) ) ? (?: : ( .* ) ) ? $ / i;
1111
12+ var escape_tags_map = {
13+ '\\\\' : '\\' ,
14+ '\\:' : ';' ,
15+ '\\s' : ' ' ,
16+ '\\n' : '\n' ,
17+ '\\r' : '\r'
18+ } ;
19+
1220function parseIrcLine ( line ) {
1321 var msg ;
1422 var tags = Object . create ( null ) ;
@@ -26,9 +34,18 @@ function parseIrcLine(line) {
2634 if ( msg [ 1 ] ) {
2735 msg [ 1 ] . split ( ';' ) . forEach ( function ( tag ) {
2836 var parts = tag . split ( '=' ) ;
29- tags [ parts [ 0 ] . toLowerCase ( ) ] = typeof parts [ 1 ] === 'undefined' ?
30- true :
31- parts [ 1 ] ;
37+ var key = parts [ 0 ] . toLowerCase ( ) ;
38+ var value = parts [ 1 ] ;
39+ if ( key ) {
40+ if ( typeof value === 'string' ) {
41+ value = value . replace ( / \\ \\ | \\ : | \\ s | \\ n | \\ r / gi, function ( matched ) {
42+ return escape_tags_map [ matched ] || '' ;
43+ } ) ;
44+ } else {
45+ value = true ;
46+ }
47+ tags [ key ] = value ;
48+ }
3249 } ) ;
3350 }
3451
You can’t perform that action at this time.
0 commit comments