[Git][noosfero/noosfero][master] 2 commits: metadata: do not expose metadata on private pages

Antonio Terceiro gitlab at gitlab.com
Tue Jul 28 13:42:37 BRT 2015


Antonio Terceiro pushed to branch master at Noosfero / noosfero


Commits:
90636c0a by Braulio Bhavamitra at 2015-07-28T12:49:45Z
metadata: do not expose metadata on private pages

- - - - -
310bb1f9 by Antonio Terceiro at 2015-07-28T16:42:04Z
Merge branch 'metadata-only-for-public-content' into 'master'

metadata: do not expose metadata on private pages

See merge request !639

- - - - -


2 changed files:

- plugins/metadata/lib/metadata_plugin.rb
- plugins/metadata/test/functional/content_viewer_controller_test.rb


Changes:

=====================================
plugins/metadata/lib/metadata_plugin.rb
=====================================
--- a/plugins/metadata/lib/metadata_plugin.rb
+++ b/plugins/metadata/lib/metadata_plugin.rb
@@ -53,6 +53,7 @@ class MetadataPlugin < Noosfero::Plugin
         when Proc then instance_exec(&variable)
         else instance_variable_get variable
         end
+      return if object.respond_to? :public? and not object.public?
       return unless specs = (object.class.metadata_specs rescue nil)
 
       r = []


=====================================
plugins/metadata/test/functional/content_viewer_controller_test.rb
=====================================
--- a/plugins/metadata/test/functional/content_viewer_controller_test.rb
+++ b/plugins/metadata/test/functional/content_viewer_controller_test.rb
@@ -57,4 +57,12 @@ class ContentViewerControllerTest < ActionController::TestCase
     end
   end
 
+  should 'not expose metadata on private pages' do
+    profile.update_column :public_profile, false
+    a = TinyMceArticle.create(name: 'Article to be shared with images', body: 'This article should be shared with all social networks <img src="/images/x.png" />', profile: profile)
+
+    get :view_page, profile: profile.identifier, page: [ a.name.to_slug ]
+    assert_no_tag tag: 'meta', attributes: { property: 'og:image', content: /\/images\/x.png/  }
+  end
+
 end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/c5a8c717a0e9ebd33f6fd37458178a0cef553b45...310bb1f93d88a2f3713ab6d16f7fc5da4529b2e4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150728/bd5d9229/attachment.html>


More information about the Noosfero-dev mailing list