Merge pull request #5510 from margori/779_remove_exif
This commit is contained in:
commit
4d8790d61e
15 changed files with 95 additions and 20 deletions
|
|
@ -145,6 +145,7 @@ diaspora.yml file**. The existing settings from 0.4.x and before will not work a
|
||||||
* Replace Pagedown with markdown-it [#5526](https://github.com/diaspora/diaspora/pull/5526)
|
* Replace Pagedown with markdown-it [#5526](https://github.com/diaspora/diaspora/pull/5526)
|
||||||
* Do not truncate notification emails anymore [#4342](https://github.com/diaspora/diaspora/issues/4342)
|
* Do not truncate notification emails anymore [#4342](https://github.com/diaspora/diaspora/issues/4342)
|
||||||
* Allows users to export their data in gzipped JSON format from their user settings page [#5499](https://github.com/diaspora/diaspora/pull/5499)
|
* Allows users to export their data in gzipped JSON format from their user settings page [#5499](https://github.com/diaspora/diaspora/pull/5499)
|
||||||
|
* Strip EXIF data from newly uploaded images [#5510](https://github.com/diaspora/diaspora/pull/5510)
|
||||||
|
|
||||||
# 0.4.1.2
|
# 0.4.1.2
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,12 @@ class UsersController < ApplicationController
|
||||||
else
|
else
|
||||||
flash[:notice] = I18n.t 'users.update.settings_not_updated'
|
flash[:notice] = I18n.t 'users.update.settings_not_updated'
|
||||||
end
|
end
|
||||||
|
elsif u[:strip_exif]
|
||||||
|
if @user.update_attributes(u)
|
||||||
|
flash[:notice] = I18n.t 'users.update.settings_updated'
|
||||||
|
else
|
||||||
|
flash[:notice] = I18n.t 'users.update.settings_not_updated'
|
||||||
|
end
|
||||||
elsif u[:language]
|
elsif u[:language]
|
||||||
if @user.update_attributes(u)
|
if @user.update_attributes(u)
|
||||||
I18n.locale = @user.language
|
I18n.locale = @user.language
|
||||||
|
|
@ -182,6 +188,7 @@ class UsersController < ApplicationController
|
||||||
:invitation_service,
|
:invitation_service,
|
||||||
:invitation_identifier,
|
:invitation_identifier,
|
||||||
:show_community_spotlight_in_stream,
|
:show_community_spotlight_in_stream,
|
||||||
|
:strip_exif,
|
||||||
:auto_follow_back,
|
:auto_follow_back,
|
||||||
:auto_follow_back_aspect_id,
|
:auto_follow_back_aspect_id,
|
||||||
:remember_me,
|
:remember_me,
|
||||||
|
|
|
||||||
|
|
@ -81,10 +81,13 @@ class Photo < ActiveRecord::Base
|
||||||
|
|
||||||
photo.random_string = SecureRandom.hex(10)
|
photo.random_string = SecureRandom.hex(10)
|
||||||
|
|
||||||
|
if photo.author.local?
|
||||||
|
photo.unprocessed_image.strip_exif = photo.author.owner.strip_exif
|
||||||
|
end
|
||||||
|
|
||||||
if params[:user_file]
|
if params[:user_file]
|
||||||
image_file = params.delete(:user_file)
|
image_file = params.delete(:user_file)
|
||||||
photo.unprocessed_image.store! image_file
|
photo.unprocessed_image.store! image_file
|
||||||
|
|
||||||
elsif params[:image_url]
|
elsif params[:image_url]
|
||||||
photo.remote_unprocessed_image_url = params[:image_url]
|
photo.remote_unprocessed_image_url = params[:image_url]
|
||||||
photo.unprocessed_image.store!
|
photo.unprocessed_image.store!
|
||||||
|
|
|
||||||
|
|
@ -489,6 +489,7 @@ class User < ActiveRecord::Base
|
||||||
:show_community_spotlight_in_stream].each do |field|
|
:show_community_spotlight_in_stream].each do |field|
|
||||||
self[field] = false
|
self[field] = false
|
||||||
end
|
end
|
||||||
|
self[:strip_exif] = true
|
||||||
self[:email] = "deletedaccount_#{self[:id]}@example.org"
|
self[:email] = "deletedaccount_#{self[:id]}@example.org"
|
||||||
|
|
||||||
random_password = SecureRandom.hex(20)
|
random_password = SecureRandom.hex(20)
|
||||||
|
|
@ -527,6 +528,6 @@ class User < ActiveRecord::Base
|
||||||
"created_at", "updated_at", "locked_at",
|
"created_at", "updated_at", "locked_at",
|
||||||
"serialized_private_key", "getting_started",
|
"serialized_private_key", "getting_started",
|
||||||
"disable_mail", "show_community_spotlight_in_stream",
|
"disable_mail", "show_community_spotlight_in_stream",
|
||||||
"email", "remove_after", "export", "exporting", "exported_at"]
|
"strip_exif", "email", "remove_after", "export", "exporting", "exported_at"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@ module Export
|
||||||
:disable_mail,
|
:disable_mail,
|
||||||
:show_community_spotlight_in_stream,
|
:show_community_spotlight_in_stream,
|
||||||
:auto_follow_back,
|
:auto_follow_back,
|
||||||
:auto_follow_back_aspect
|
:auto_follow_back_aspect,
|
||||||
|
:strip_exif
|
||||||
has_one :profile, serializer: Export::ProfileSerializer
|
has_one :profile, serializer: Export::ProfileSerializer
|
||||||
has_many :aspects, each_serializer: Export::AspectSerializer
|
has_many :aspects, each_serializer: Export::AspectSerializer
|
||||||
has_many :contacts, each_serializer: Export::ContactSerializer
|
has_many :contacts, each_serializer: Export::ContactSerializer
|
||||||
|
|
@ -19,4 +20,4 @@ module Export
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -19,27 +19,15 @@ class ProcessedImage < CarrierWave::Uploader::Base
|
||||||
|
|
||||||
version :thumb_small do
|
version :thumb_small do
|
||||||
process :resize_to_fill => [50,50]
|
process :resize_to_fill => [50,50]
|
||||||
process :strip
|
|
||||||
end
|
end
|
||||||
version :thumb_medium do
|
version :thumb_medium do
|
||||||
process :resize_to_limit => [100,100]
|
process :resize_to_limit => [100,100]
|
||||||
process :strip
|
|
||||||
end
|
end
|
||||||
version :thumb_large do
|
version :thumb_large do
|
||||||
process :resize_to_limit => [300,300]
|
process :resize_to_limit => [300,300]
|
||||||
process :strip
|
|
||||||
end
|
end
|
||||||
version :scaled_full do
|
version :scaled_full do
|
||||||
process :resize_to_limit => [700,nil]
|
process :resize_to_limit => [700,nil]
|
||||||
process :strip
|
|
||||||
end
|
|
||||||
|
|
||||||
def strip
|
|
||||||
manipulate! do |img|
|
|
||||||
img.strip
|
|
||||||
img = yield(img) if block_given?
|
|
||||||
img
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,12 @@
|
||||||
class UnprocessedImage < CarrierWave::Uploader::Base
|
class UnprocessedImage < CarrierWave::Uploader::Base
|
||||||
include CarrierWave::MiniMagick
|
include CarrierWave::MiniMagick
|
||||||
|
|
||||||
|
attr_accessor :strip_exif
|
||||||
|
|
||||||
|
def strip_exif
|
||||||
|
@strip_exif || false
|
||||||
|
end
|
||||||
|
|
||||||
def store_dir
|
def store_dir
|
||||||
"uploads/images"
|
"uploads/images"
|
||||||
end
|
end
|
||||||
|
|
@ -17,11 +23,13 @@ class UnprocessedImage < CarrierWave::Uploader::Base
|
||||||
model.random_string + File.extname(@filename) if @filename
|
model.random_string + File.extname(@filename) if @filename
|
||||||
end
|
end
|
||||||
|
|
||||||
process :orient_image
|
process :basic_process
|
||||||
|
|
||||||
def orient_image
|
def basic_process
|
||||||
manipulate! do |img|
|
manipulate! do |img|
|
||||||
img.auto_orient
|
img.auto_orient
|
||||||
|
img.strip if strip_exif
|
||||||
|
img = yield(img) if block_given?
|
||||||
img
|
img
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,26 @@
|
||||||
= t('privacy')
|
= t('privacy')
|
||||||
= render 'shared/settings_nav'
|
= render 'shared/settings_nav'
|
||||||
|
|
||||||
|
.row-fluid
|
||||||
|
.span3
|
||||||
|
.span5
|
||||||
|
%h3
|
||||||
|
= t('.title')
|
||||||
|
|
||||||
|
= form_for current_user, :url => user_path, :html => { :method => :put } do |f|
|
||||||
|
= f.error_messages
|
||||||
|
|
||||||
|
= f.fields_for :stream_preferences do |type|
|
||||||
|
#stream_prefs
|
||||||
|
= f.label :strip_exif, :class => "checkbox" do
|
||||||
|
= f.check_box :strip_exif
|
||||||
|
= t('.strip_exif')
|
||||||
|
|
||||||
|
.small-horizontal-spacer
|
||||||
|
= f.submit t('.change'), :class => 'btn'
|
||||||
|
|
||||||
|
%hr
|
||||||
|
|
||||||
.row-fluid
|
.row-fluid
|
||||||
.span3
|
.span3
|
||||||
.span5
|
.span5
|
||||||
|
|
|
||||||
|
|
@ -1316,8 +1316,10 @@ en:
|
||||||
privacy_settings:
|
privacy_settings:
|
||||||
title: "Privacy Settings"
|
title: "Privacy Settings"
|
||||||
ignored_users: "Ignored Users"
|
ignored_users: "Ignored Users"
|
||||||
|
strip_exif: "Strip metadata such as location, author, and camera model from uploaded images (recommended)"
|
||||||
stop_ignoring: "Stop ignoring"
|
stop_ignoring: "Stop ignoring"
|
||||||
no_user_ignored_message: "You are currently ignoring no other user"
|
no_user_ignored_message: "You are currently ignoring no other user"
|
||||||
|
change: "Change"
|
||||||
|
|
||||||
destroy:
|
destroy:
|
||||||
success: "Your account has been locked. It may take 20 minutes for us to finish closing your account. Thank you for trying diaspora*."
|
success: "Your account has been locked. It may take 20 minutes for us to finish closing your account. Thank you for trying diaspora*."
|
||||||
|
|
|
||||||
9
db/migrate/20141230214830_user_pref_strip_exif.rb
Normal file
9
db/migrate/20141230214830_user_pref_strip_exif.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
class UserPrefStripExif < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
add_column :users, :strip_exif, :boolean, default: true
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_column :users, :strip_exif
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20141227120907) do
|
ActiveRecord::Schema.define(version: 20141230214830) do
|
||||||
|
|
||||||
create_table "account_deletions", force: true do |t|
|
create_table "account_deletions", force: true do |t|
|
||||||
t.string "diaspora_handle"
|
t.string "diaspora_handle"
|
||||||
|
|
@ -558,6 +558,7 @@ ActiveRecord::Schema.define(version: 20141227120907) do
|
||||||
t.datetime "reset_password_sent_at"
|
t.datetime "reset_password_sent_at"
|
||||||
t.datetime "last_seen"
|
t.datetime "last_seen"
|
||||||
t.datetime "remove_after"
|
t.datetime "remove_after"
|
||||||
|
t.boolean "strip_exif", default: true
|
||||||
t.string "export"
|
t.string "export"
|
||||||
t.datetime "exported_at"
|
t.datetime "exported_at"
|
||||||
t.boolean "exporting", default: false
|
t.boolean "exporting", default: false
|
||||||
|
|
|
||||||
BIN
spec/fixtures/exif.jpg
vendored
Normal file
BIN
spec/fixtures/exif.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 115 KiB |
|
|
@ -37,6 +37,7 @@ describe Diaspora::Exporter do
|
||||||
it { matches :user, :show_community_spotlight_in_stream }
|
it { matches :user, :show_community_spotlight_in_stream }
|
||||||
it { matches :user, :auto_follow_back }
|
it { matches :user, :auto_follow_back }
|
||||||
it { matches :user, :auto_follow_back_aspect }
|
it { matches :user, :auto_follow_back_aspect }
|
||||||
|
it { matches :user, :strip_exif }
|
||||||
|
|
||||||
it { matches :user, :profile, :first_name, root: @user1.person.profile }
|
it { matches :user, :profile, :first_name, root: @user1.person.profile }
|
||||||
it { matches :user, :profile, :last_name, root: @user1.person.profile }
|
it { matches :user, :profile, :last_name, root: @user1.person.profile }
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,39 @@ describe Photo, :type => :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with a saved photo containing EXIF data' do
|
||||||
|
before do
|
||||||
|
@exif_filename = 'exif.jpg'
|
||||||
|
@exif_name = File.join(File.dirname(__FILE__), '..', 'fixtures', @exif_filename)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should contain EXIF data if user prefer' do
|
||||||
|
@alice_photo = alice.build_post(:photo, :user_file => File.open(@exif_name), :to => alice.aspects.first.id)
|
||||||
|
|
||||||
|
with_carrierwave_processing do
|
||||||
|
@alice_photo.unprocessed_image.store! File.open(@exif_name)
|
||||||
|
@alice_photo.save
|
||||||
|
end
|
||||||
|
|
||||||
|
new_filename = File.join(File.dirname(__FILE__), '../../public/', @alice_photo.unprocessed_image.store_dir, @alice_photo.unprocessed_image.filename)
|
||||||
|
image = MiniMagick::Image.new(new_filename)
|
||||||
|
expect(image.exif.length).not_to eq(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not contain EXIF data if user prefer' do
|
||||||
|
@bob_photo = bob.build_post(:photo, :user_file => File.open(@exif_name), :to => @aspect.id)
|
||||||
|
|
||||||
|
with_carrierwave_processing do
|
||||||
|
@bob_photo.unprocessed_image.store! File.open(@exif_name)
|
||||||
|
@bob_photo.save
|
||||||
|
end
|
||||||
|
|
||||||
|
new_filename = File.join(File.dirname(__FILE__), '../../public/', @bob_photo.unprocessed_image.store_dir, @bob_photo.unprocessed_image.filename)
|
||||||
|
image = MiniMagick::Image.new(new_filename)
|
||||||
|
expect(image.exif.length).to eq(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'non-image files' do
|
describe 'non-image files' do
|
||||||
it 'should not store' do
|
it 'should not store' do
|
||||||
file = File.open(@fail_fixture_name)
|
file = File.open(@fail_fixture_name)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ FixtureBuilder.configure do |fbuilder|
|
||||||
# now declare objects
|
# now declare objects
|
||||||
fbuilder.factory do
|
fbuilder.factory do
|
||||||
# Users
|
# Users
|
||||||
alice = FactoryGirl.create(:user_with_aspect, :username => "alice")
|
alice = FactoryGirl.create(:user_with_aspect, :username => "alice", :strip_exif => false)
|
||||||
alices_aspect = alice.aspects.where(:name => "generic").first
|
alices_aspect = alice.aspects.where(:name => "generic").first
|
||||||
|
|
||||||
eve = FactoryGirl.create(:user_with_aspect, :username => "eve")
|
eve = FactoryGirl.create(:user_with_aspect, :username => "eve")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue