Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
502d3bdc
Unverified
Commit
502d3bdc
authored
1 year ago
by
Sébastien Gaya
Browse files
Options
Downloads
Patches
Plain Diff
fix embed blocks from indirect source
parent
5a9c7da9
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/models/communication/website/with_associated_objects.rb
+17
-1
17 additions, 1 deletion
app/models/communication/website/with_associated_objects.rb
app/models/communication/website/with_security.rb
+7
-4
7 additions, 4 deletions
app/models/communication/website/with_security.rb
with
24 additions
and
5 deletions
app/models/communication/website/with_associated_objects.rb
+
17
−
1
View file @
502d3bdc
...
...
@@ -21,7 +21,7 @@ module Communication::Website::WithAssociatedObjects
has_many :permalinks,
class_name: "Communication::Website::Permalink",
dependent: :destroy
has_many :communication_blocks,
class_name: "Communication::Block",
foreign_key: :communication_website_id
...
...
@@ -29,6 +29,22 @@ module Communication::Website::WithAssociatedObjects
end
def blocks_from_education
Communication::Block.where(about: education_programs).or(
Communication::Block.where(about: education_diplomas)
)
end
def blocks_from_research
Communication::Block.where(about: research_papers)
end
def blocks_from_university
Communication::Block.where(about: connected_people).or(
Communication::Block.where(about: connected_organizations)
)
end
def education_diplomas
has_education_diplomas? ? about.diplomas : Education::Diploma.none
end
...
...
This diff is collapsed.
Click to expand it.
app/models/communication/website/with_security.rb
+
7
−
4
View file @
502d3bdc
...
...
@@ -5,7 +5,10 @@ module Communication::Website::WithSecurity
list = external_domains_default
list.concat external_domains_plausible
list.concat external_domains_from_blocks_video
list.concat external_domains_from_blocks_embed
list.concat external_domains_from_blocks_embed(blocks)
list.concat external_domains_from_blocks_embed(blocks_from_education)
list.concat external_domains_from_blocks_embed(blocks_from_research)
list.concat external_domains_from_blocks_embed(blocks_from_university)
list.uniq.compact
end
...
...
@@ -34,14 +37,14 @@ module Communication::Website::WithSecurity
list
end
def external_domains_from_blocks_embed
def external_domains_from_blocks_embed
(blocks)
list = []
blocks.where(template_kind: :embed).each do |block|
blocks.where(template_kind: :embed).
published.
each do |block|
code = block.template.code
# https://stackoverflow.com/questions/25095176/extracting-all-urls-from-a-page-using-ruby
code.scan(/[[:lower:]]+:\/\/[^\s"]+/).each do |url|
url = CGI.unescapeHTML(url)
url =
ActionController::Base.helpers.strip_tags(url)
url = ActionController::Base.helpers.strip_tags(url)
url = URI::Parser.new.escape(url)
host = URI.parse(url).host
list << host
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment