Commit 310bb1f93d88a2f3713ab6d16f7fc5da4529b2e4
Exists in
master
and in
9 other branches
Merge branch 'metadata-only-for-public-content' into 'master'
metadata: do not expose metadata on private pages See merge request !639
Showing
2 changed files
with
9 additions
and
0 deletions
Show diff stats
plugins/metadata/lib/metadata_plugin.rb
@@ -53,6 +53,7 @@ class MetadataPlugin < Noosfero::Plugin | @@ -53,6 +53,7 @@ class MetadataPlugin < Noosfero::Plugin | ||
53 | when Proc then instance_exec(&variable) | 53 | when Proc then instance_exec(&variable) |
54 | else instance_variable_get variable | 54 | else instance_variable_get variable |
55 | end | 55 | end |
56 | + return if object.respond_to? :public? and not object.public? | ||
56 | return unless specs = (object.class.metadata_specs rescue nil) | 57 | return unless specs = (object.class.metadata_specs rescue nil) |
57 | 58 | ||
58 | r = [] | 59 | r = [] |
plugins/metadata/test/functional/content_viewer_controller_test.rb
@@ -57,4 +57,12 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -57,4 +57,12 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
57 | end | 57 | end |
58 | end | 58 | end |
59 | 59 | ||
60 | + should 'not expose metadata on private pages' do | ||
61 | + profile.update_column :public_profile, false | ||
62 | + 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) | ||
63 | + | ||
64 | + get :view_page, profile: profile.identifier, page: [ a.name.to_slug ] | ||
65 | + assert_no_tag tag: 'meta', attributes: { property: 'og:image', content: /\/images\/x.png/ } | ||
66 | + end | ||
67 | + | ||
60 | end | 68 | end |