FIX: ico are images too
This commit is contained in:
parent
af91d6f35b
commit
bebeeffc30
|
@ -256,17 +256,17 @@ Discourse.Utilities = {
|
||||||
},
|
},
|
||||||
|
|
||||||
isAnImage: function(path) {
|
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() {
|
allowsImages: function() {
|
||||||
return Discourse.Utilities.authorizesAllExtensions() ||
|
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() {
|
allowsAttachments: function() {
|
||||||
return Discourse.Utilities.authorizesAllExtensions() ||
|
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) {
|
displayErrorForUpload: function(data) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ class UsernameValidator
|
||||||
|
|
||||||
def username_does_not_end_with_confusing_suffix?
|
def username_does_not_end_with_confusing_suffix?
|
||||||
return unless errors.empty?
|
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')
|
self.errors << I18n.t(:'user.username.must_not_contain_confusing_suffix')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,7 +28,7 @@ class FileHelper
|
||||||
private
|
private
|
||||||
|
|
||||||
def self.images
|
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
|
end
|
||||||
|
|
||||||
def self.images_regexp
|
def self.images_regexp
|
||||||
|
|
|
@ -95,7 +95,7 @@ test("getUploadMarkdown", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("isAnImage", 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;
|
var image = "image." + extension;
|
||||||
ok(utils.isAnImage(image), image + " is recognized as an image");
|
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");
|
ok(utils.isAnImage("http://foo.bar/path/to/" + image), image + " is recognized as an image");
|
||||||
|
|
Loading…
Reference in New Issue