Escape dots in plugin regexes

See #519
This commit is contained in:
Lorenz Hübschle-Schneider 2016-11-01 13:07:12 +01:00 committed by GitHub
parent 03af5d7158
commit 71d2cefce1

View file

@ -196,7 +196,7 @@ plugins.factory('userPlugins', function() {
} }
}; };
addMatch(message.match(/spotify:track:([a-zA-Z-0-9]{22})/g)); addMatch(message.match(/spotify:track:([a-zA-Z-0-9]{22})/g));
addMatch(message.match(/open.spotify.com\/track\/([a-zA-Z-0-9]{22})/g)); addMatch(message.match(/open\.spotify\.com\/track\/([a-zA-Z-0-9]{22})/g));
return content; return content;
}); });
@ -206,7 +206,7 @@ plugins.factory('userPlugins', function() {
* See: https://developers.google.com/youtube/player_parameters * See: https://developers.google.com/youtube/player_parameters
*/ */
var youtubePlugin = new UrlPlugin('YouTube video', function(url) { var youtubePlugin = new UrlPlugin('YouTube video', function(url) {
var regex = /(?:youtube.com|youtu.be)\/(?:v\/|embed\/|watch(?:\?v=|\/))?([a-zA-Z0-9_-]+)/i, var regex = /(?:youtube\.com|youtu\.be)\/(?:v\/|embed\/|watch(?:\?v=|\/))?([a-zA-Z0-9_-]+)/i,
match = url.match(regex); match = url.match(regex);
if (match){ if (match){
@ -228,9 +228,9 @@ plugins.factory('userPlugins', function() {
* See: http://www.dailymotion.com/doc/api/player.html * See: http://www.dailymotion.com/doc/api/player.html
*/ */
var dailymotionPlugin = new Plugin('Dailymotion video', function(message) { var dailymotionPlugin = new Plugin('Dailymotion video', function(message) {
var rPath = /dailymotion.com\/.*video\/([^_?# ]+)/; var rPath = /dailymotion\.com\/.*video\/([^_?# ]+)/;
var rAnchor = /dailymotion.com\/.*#video=([^_& ]+)/; var rAnchor = /dailymotion\.com\/.*#video=([^_& ]+)/;
var rShorten = /dai.ly\/([^_?# ]+)/; var rShorten = /dai\.ly\/([^_?# ]+)/;
var match = message.match(rPath) || message.match(rAnchor) || message.match(rShorten); var match = message.match(rPath) || message.match(rAnchor) || message.match(rShorten);
if (match) { if (match) {
@ -251,8 +251,8 @@ plugins.factory('userPlugins', function() {
* AlloCine Embedded Player * AlloCine Embedded Player
*/ */
var allocinePlugin = new Plugin('AlloCine video', function(message) { var allocinePlugin = new Plugin('AlloCine video', function(message) {
var rVideokast = /allocine.fr\/videokast\/video-(\d+)/; var rVideokast = /allocine\.fr\/videokast\/video-(\d+)/;
var rCmedia = /allocine.fr\/.*cmedia=(\d+)/; var rCmedia = /allocine\.fr\/.*cmedia=(\d+)/;
var match = message.match(rVideokast) || message.match(rCmedia); var match = message.match(rVideokast) || message.match(rCmedia);
if (match) { if (match) {
@ -359,7 +359,7 @@ plugins.factory('userPlugins', function() {
var cloudmusicPlugin = new UrlPlugin('cloud music', function(url) { var cloudmusicPlugin = new UrlPlugin('cloud music', function(url) {
/* SoundCloud http://help.soundcloud.com/customer/portal/articles/247785-what-widgets-can-i-use-from-soundcloud- */ /* SoundCloud http://help.soundcloud.com/customer/portal/articles/247785-what-widgets-can-i-use-from-soundcloud- */
var element; var element;
if (url.match(/^https?:\/\/soundcloud.com\//)) { if (url.match(/^https?:\/\/soundcloud\.com\//)) {
element = angular.element('<iframe></iframe>') element = angular.element('<iframe></iframe>')
.attr('width', '100%') .attr('width', '100%')
.attr('height', '120') .attr('height', '120')
@ -370,7 +370,7 @@ plugins.factory('userPlugins', function() {
} }
/* MixCloud */ /* MixCloud */
if (url.match(/^https?:\/\/([a-z]+\.)?mixcloud.com\//)) { if (url.match(/^https?:\/\/([a-z]+\.)?mixcloud\.com\//)) {
element = angular.element('<iframe></iframe>') element = angular.element('<iframe></iframe>')
.attr('width', '480') .attr('width', '480')
.attr('height', '60') .attr('height', '60')
@ -400,7 +400,7 @@ plugins.factory('userPlugins', function() {
* Asciinema plugin * Asciinema plugin
*/ */
var asciinemaPlugin = new UrlPlugin('ascii cast', function(url) { var asciinemaPlugin = new UrlPlugin('ascii cast', function(url) {
var regexp = /^https?:\/\/(?:www\.)?asciinema.org\/a\/([0-9a-z]+)/i, var regexp = /^https?:\/\/(?:www\.)?asciinema\.org\/a\/([0-9a-z]+)/i,
match = url.match(regexp); match = url.match(regexp);
if (match) { if (match) {
var id = match[1]; var id = match[1];
@ -436,7 +436,7 @@ plugins.factory('userPlugins', function() {
// Embed GitHub gists // Embed GitHub gists
var gistPlugin = new UrlPlugin('Gist', function(url) { var gistPlugin = new UrlPlugin('Gist', function(url) {
// ignore trailing slashes and anchors // ignore trailing slashes and anchors
var regexp = /^(https:\/\/gist\.github.com\/(?:.*?))[\/]?(?:\#.*)?$/i; var regexp = /^(https:\/\/gist\.github\.com\/(?:.*?))[\/]?(?:\#.*)?$/i;
var match = url.match(regexp); var match = url.match(regexp);
if (match) { if (match) {
// get the URL from the match to trim away pseudo file endings and request parameters // get the URL from the match to trim away pseudo file endings and request parameters
@ -457,7 +457,7 @@ plugins.factory('userPlugins', function() {
}); });
var pastebinPlugin = new UrlPlugin('Pastebin', function(url) { var pastebinPlugin = new UrlPlugin('Pastebin', function(url) {
var regexp = /^https?:\/\/pastebin.com\/([^.?]+)/i; var regexp = /^https?:\/\/pastebin\.com\/([^.?]+)/i;
var match = url.match(regexp); var match = url.match(regexp);
if (match) { if (match) {
var id = match[1], var id = match[1],
@ -475,7 +475,7 @@ plugins.factory('userPlugins', function() {
* sample output: https://media.giphy.com/media/feqkVgjJpYtjy/giphy.gif * sample output: https://media.giphy.com/media/feqkVgjJpYtjy/giphy.gif
*/ */
var giphyPlugin = new UrlPlugin('Giphy', function(url) { var giphyPlugin = new UrlPlugin('Giphy', function(url) {
var regex = /^https?:\/\/giphy.com\/gifs\/.*-(.*)\/?/i; var regex = /^https?:\/\/giphy\.com\/gifs\/.*-(.*)\/?/i;
// on match, id will contain the entire url in [0] and the giphy id in [1] // on match, id will contain the entire url in [0] and the giphy id in [1]
var id = url.match(regex); var id = url.match(regex);
if (id) { if (id) {
@ -522,7 +522,7 @@ plugins.factory('userPlugins', function() {
* Vine plugin * Vine plugin
*/ */
var vinePlugin = new UrlPlugin('Vine', function (url) { var vinePlugin = new UrlPlugin('Vine', function (url) {
var regexp = /^https?:\/\/(www\.)?vine.co\/v\/([a-zA-Z0-9]+)(\/.*)?/i, var regexp = /^https?:\/\/(www\.)?vine\.co\/v\/([a-zA-Z0-9]+)(\/.*)?/i,
match = url.match(regexp); match = url.match(regexp);
if (match) { if (match) {
var id = match[2], embedurl = "https://vine.co/v/" + id + "/embed/simple?audio=1"; var id = match[2], embedurl = "https://vine.co/v/" + id + "/embed/simple?audio=1";