FIX: ico are images too

This commit is contained in:
Régis Hanol 2015-12-31 11:40:23 +01:00
parent af91d6f35b
commit bebeeffc30
4 changed files with 6 additions and 6 deletions

View File

@ -256,17 +256,17 @@ Discourse.Utilities = {
},
isAnImage: function(path) {
return (/\.(png|jpe?g|gif|bmp|tiff?|svg|webp)$/i).test(path);
return (/\.(png|jpe?g|gif|bmp|tiff?|svg|webp|ico)$/i).test(path);
},
allowsImages: function() {
return Discourse.Utilities.authorizesAllExtensions() ||
(/(png|jpe?g|gif|bmp|tiff?|svg|webp)/i).test(Discourse.Utilities.authorizedExtensions());
(/(png|jpe?g|gif|bmp|tiff?|svg|webp|ico)/i).test(Discourse.Utilities.authorizedExtensions());
},
allowsAttachments: function() {
return Discourse.Utilities.authorizesAllExtensions() ||
!(/((png|jpe?g|gif|bmp|tiff?|svg|webp)(,\s)?)+$/i).test(Discourse.Utilities.authorizedExtensions());
!(/((png|jpe?g|gif|bmp|tiff?|svg|web|ico)(,\s)?)+$/i).test(Discourse.Utilities.authorizedExtensions());
},
displayErrorForUpload: function(data) {

View File

@ -89,7 +89,7 @@ class UsernameValidator
def username_does_not_end_with_confusing_suffix?
return unless errors.empty?
if username =~ /\.(json|gif|jpeg|png|htm|js|json|xml|woff|tif|html)/i
if username =~ /\.(json|gif|jpeg|png|htm|js|json|xml|woff|tif|html|ico)/i
self.errors << I18n.t(:'user.username.must_not_contain_confusing_suffix')
end
end

View File

@ -28,7 +28,7 @@ class FileHelper
private
def self.images
@@images ||= Set.new ["jpg", "jpeg", "png", "gif", "tif", "tiff", "bmp", "svg", "webp"]
@@images ||= Set.new ["jpg", "jpeg", "png", "gif", "tif", "tiff", "bmp", "svg", "webp", "ico"]
end
def self.images_regexp

View File

@ -95,7 +95,7 @@ test("getUploadMarkdown", function() {
});
test("isAnImage", function() {
_.each(["png", "jpg", "jpeg", "bmp", "gif", "tif", "tiff"], function(extension) {
_.each(["png", "jpg", "jpeg", "bmp", "gif", "tif", "tiff", "ico"], function(extension) {
var image = "image." + extension;
ok(utils.isAnImage(image), image + " is recognized as an image");
ok(utils.isAnImage("http://foo.bar/path/to/" + image), image + " is recognized as an image");