Browse Source

fixed some escaping

Markus-Rost 6 years ago
parent
commit
767673a920
1 changed files with 4 additions and 4 deletions
  1. 4 4
      main.js

+ 4 - 4
main.js

@@ -1104,7 +1104,7 @@ function cmd_bug(lang, mclang, msg, args, title, cmd, querystring, fragment) {
 					else {
 						var status = '**' + ( body.fields.resolution ? body.fields.resolution.name : body.fields.status.name ) + ':** ';
 						var fixed = ( body.fields.resolution && body.fields.fixVersions.length ? mclang.bug.fixed + ' ' + body.fields.fixVersions.map( v => v.name ).join(', ') : '' );
-						msg.channel.sendMsg( status + body.fields.summary + '\n<https://bugs.mojang.com/browse/' + body.key + '>\n' + fixed );
+						msg.channel.sendMsg( status + body.fields.summary.replace( /@(here|everyone)/g, '%40$1' ) + '\n<https://bugs.mojang.com/browse/' + body.key + '>\n' + fixed );
 					}
 				}
 				
@@ -1253,7 +1253,7 @@ Array.prototype.toEmojis = function() {
 };
 
 String.prototype.toTitle = function(isMarkdown = false) {
-	var title = this.replace( / /g, '_' ).replace( /\%/g, '%25' ).replace( /\?/g, '%3F' );
+	var title = this.replace( / /g, '_' ).replace( /\%/g, '%25' ).replace( /\?/g, '%3F' ).replace( /@(here|everyone)/g, '%40$1' );
 	if ( isMarkdown ) title = title.replace( /(\(|\))/g, '\\$1' );
 	return title;
 };
@@ -1282,11 +1282,11 @@ String.prototype.toMarkdown = function(wiki, title = '') {
 		var page = title.toTitle(true) + '#' + link[1].toSection();
 		text = text.replace( link[0], '[→](https://' + wiki + '.gamepedia.com/' + page + ')' + link[1] + ( link[2] ? ': ' + link[2] : '' ) );
 	}
-	return text.replace( /(`|_|\*|~|<|>|{|}|\/)/g, '\\$1' );
+	return text.replace( /(`|_|\*|~|<|>|{|}|\||\/\/)/g, '\\$1' );
 };
 
 String.prototype.toPlaintext = function() {
-	return this.replace( /\[\[(?:[^\|\]]+\|)?([^\]]+)\]\]/g, '$1' ).replace( /\/\*\s*([^\*]+?)\s*\*\//g, '→$1:' ).replace( /(`|_|\*|~|<|>|{|}|\/)/g, '\\$1' );
+	return this.replace( /\[\[(?:[^\|\]]+\|)?([^\]]+)\]\]/g, '$1' ).replace( /\/\*\s*([^\*]+?)\s*\*\//g, '→$1:' ).replace( /(`|_|\*|~|<|>|{|}|\||\/\/)/g, '\\$1' );
 };
 
 Discord.Message.prototype.reactEmoji = function(name) {