Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
e8d0d6ba
Commit
e8d0d6ba
authored
Dec 11, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use app host instead of asset host when rendering image blob or diff
parent
fb47f2a7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
21 deletions
+39
-21
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+9
-5
app/helpers/diff_helper.rb
app/helpers/diff_helper.rb
+12
-4
app/views/projects/blob/viewers/_image.html.haml
app/views/projects/blob/viewers/_image.html.haml
+2
-1
app/views/projects/diffs/_replaced_image_diff.html.haml
app/views/projects/diffs/_replaced_image_diff.html.haml
+8
-8
app/views/projects/diffs/_single_image_diff.html.haml
app/views/projects/diffs/_single_image_diff.html.haml
+3
-3
changelogs/unreleased/dm-image-blob-diff-full-url.yml
changelogs/unreleased/dm-image-blob-diff-full-url.yml
+5
-0
No files found.
app/helpers/blob_helper.rb
View file @
e8d0d6ba
...
@@ -118,20 +118,24 @@ module BlobHelper
...
@@ -118,20 +118,24 @@ module BlobHelper
icon
(
"
#{
file_type_icon_class
(
'file'
,
mode
,
name
)
}
fw"
)
icon
(
"
#{
file_type_icon_class
(
'file'
,
mode
,
name
)
}
fw"
)
end
end
def
blob_raw_
path
def
blob_raw_
url
(
only_path:
false
)
if
@build
&&
@entry
if
@build
&&
@entry
raw_project_job_artifacts_
path
(
@project
,
@build
,
path:
@entry
.
path
)
raw_project_job_artifacts_
url
(
@project
,
@build
,
path:
@entry
.
path
,
only_path:
only_
path
)
elsif
@snippet
elsif
@snippet
if
@snippet
.
project_id
if
@snippet
.
project_id
raw_project_snippet_
path
(
@project
,
@snippet
)
raw_project_snippet_
url
(
@project
,
@snippet
,
only_path:
only_path
)
else
else
raw_snippet_
path
(
@snippet
)
raw_snippet_
url
(
@snippet
,
only_path:
only_path
)
end
end
elsif
@blob
elsif
@blob
project_raw_
path
(
@project
,
@id
)
project_raw_
url
(
@project
,
@id
,
only_path:
only_path
)
end
end
end
end
def
blob_raw_path
blob_raw_url
(
only_path:
true
)
end
# SVGs can contain malicious JavaScript; only include whitelisted
# SVGs can contain malicious JavaScript; only include whitelisted
# elements and attributes. Note that this whitelist is by no means complete
# elements and attributes. Note that this whitelist is by no means complete
# and may omit some elements.
# and may omit some elements.
...
...
app/helpers/diff_helper.rb
View file @
e8d0d6ba
...
@@ -104,15 +104,23 @@ module DiffHelper
...
@@ -104,15 +104,23 @@ module DiffHelper
].
join
(
' '
).
html_safe
].
join
(
' '
).
html_safe
end
end
def
diff_file_blob_raw_
path
(
diff_fil
e
)
def
diff_file_blob_raw_
url
(
diff_file
,
only_path:
fals
e
)
project_raw_
path
(
@project
,
tree_join
(
diff_file
.
content_sha
,
diff_file
.
file_path
)
)
project_raw_
url
(
@project
,
tree_join
(
diff_file
.
content_sha
,
diff_file
.
file_path
),
only_path:
only_path
)
end
end
def
diff_file_old_blob_raw_
path
(
diff_fil
e
)
def
diff_file_old_blob_raw_
url
(
diff_file
,
only_path:
fals
e
)
sha
=
diff_file
.
old_content_sha
sha
=
diff_file
.
old_content_sha
return
unless
sha
return
unless
sha
project_raw_path
(
@project
,
tree_join
(
diff_file
.
old_content_sha
,
diff_file
.
old_path
))
project_raw_url
(
@project
,
tree_join
(
diff_file
.
old_content_sha
,
diff_file
.
old_path
),
only_path:
only_path
)
end
def
diff_file_blob_raw_path
(
diff_file
)
diff_file_blob_raw_url
(
diff_file
,
only_path:
true
)
end
def
diff_file_old_blob_raw_path
(
diff_file
)
diff_file_old_blob_raw_url
(
diff_file
,
only_path:
true
)
end
end
def
diff_file_html_data
(
project
,
diff_file_path
,
diff_commit_id
)
def
diff_file_html_data
(
project
,
diff_file_path
,
diff_commit_id
)
...
...
app/views/projects/blob/viewers/_image.html.haml
View file @
e8d0d6ba
.file-content.image_file
.file-content.image_file
=
image_tag
(
blob_raw_path
,
alt:
viewer
.
blob
.
name
)
-# Uses the full URL rather than the path, to prevent it from getting prefixed with the asset host.
=
image_tag
(
blob_raw_url
,
alt:
viewer
.
blob
.
name
)
app/views/projects/diffs/_replaced_image_diff.html.haml
View file @
e8d0d6ba
-
blob
=
diff_file
.
blob
-
blob
=
diff_file
.
blob
-
old_blob
=
diff_file
.
old_blob
-
old_blob
=
diff_file
.
old_blob
-
blob_raw_
path
=
diff_file_blob_raw_path
(
diff_file
)
-
blob_raw_
url
=
diff_file_blob_raw_url
(
diff_file
)
-
old_blob_raw_
path
=
diff_file_old_blob_raw_path
(
diff_file
)
-
old_blob_raw_
url
=
diff_file_old_blob_raw_url
(
diff_file
)
-
click_to_comment
=
local_assigns
.
fetch
(
:click_to_comment
,
true
)
-
click_to_comment
=
local_assigns
.
fetch
(
:click_to_comment
,
true
)
-
diff_view_data
=
local_assigns
.
fetch
(
:diff_view_data
,
''
)
-
diff_view_data
=
local_assigns
.
fetch
(
:diff_view_data
,
''
)
-
class_name
=
''
-
class_name
=
''
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
.two-up.view
.two-up.view
.wrap
.wrap
.frame.deleted
.frame.deleted
=
image_tag
(
old_blob_raw_
path
,
alt:
diff_file
.
old_path
,
lazy:
false
)
=
image_tag
(
old_blob_raw_
url
,
alt:
diff_file
.
old_path
,
lazy:
false
)
%p
.image-info.hide
%p
.image-info.hide
%span
.meta-filesize
=
number_to_human_size
(
old_blob
.
size
)
%span
.meta-filesize
=
number_to_human_size
(
old_blob
.
size
)
|
|
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
%strong
H:
%strong
H:
%span
.meta-height
%span
.meta-height
.wrap
.wrap
=
render
partial:
"projects/diffs/image_diff_frame"
,
locals:
{
class_name:
"added js-image-frame
#{
class_name
}
"
,
position:
position
,
note_type:
DiffNote
.
name
,
image_path:
blob_raw_
path
,
alt:
diff_file
.
new_path
}
=
render
partial:
"projects/diffs/image_diff_frame"
,
locals:
{
class_name:
"added js-image-frame
#{
class_name
}
"
,
position:
position
,
note_type:
DiffNote
.
name
,
image_path:
blob_raw_
url
,
alt:
diff_file
.
new_path
}
%p
.image-info.hide
%p
.image-info.hide
%span
.meta-filesize
=
number_to_human_size
(
blob
.
size
)
%span
.meta-filesize
=
number_to_human_size
(
blob
.
size
)
|
|
...
@@ -36,9 +36,9 @@
...
@@ -36,9 +36,9 @@
.swipe.view.hide
.swipe.view.hide
.swipe-frame
.swipe-frame
.frame.deleted
.frame.deleted
=
image_tag
(
old_blob_raw_
path
,
alt:
diff_file
.
old_path
,
lazy:
false
)
=
image_tag
(
old_blob_raw_
url
,
alt:
diff_file
.
old_path
,
lazy:
false
)
.swipe-wrap
.swipe-wrap
=
render
partial:
"projects/diffs/image_diff_frame"
,
locals:
{
class_name:
"added js-image-frame
#{
class_name
}
"
,
position:
position
,
note_type:
DiffNote
.
name
,
image_path:
blob_raw_
path
,
alt:
diff_file
.
new_path
}
=
render
partial:
"projects/diffs/image_diff_frame"
,
locals:
{
class_name:
"added js-image-frame
#{
class_name
}
"
,
position:
position
,
note_type:
DiffNote
.
name
,
image_path:
blob_raw_
url
,
alt:
diff_file
.
new_path
}
%span
.swipe-bar
%span
.swipe-bar
%span
.top-handle
%span
.top-handle
%span
.bottom-handle
%span
.bottom-handle
...
@@ -46,8 +46,8 @@
...
@@ -46,8 +46,8 @@
.onion-skin.view.hide
.onion-skin.view.hide
.onion-skin-frame
.onion-skin-frame
.frame.deleted
.frame.deleted
=
image_tag
(
old_blob_raw_
path
,
alt:
diff_file
.
old_path
,
lazy:
false
)
=
image_tag
(
old_blob_raw_
url
,
alt:
diff_file
.
old_path
,
lazy:
false
)
=
render
partial:
"projects/diffs/image_diff_frame"
,
locals:
{
class_name:
"added js-image-frame
#{
class_name
}
"
,
position:
position
,
note_type:
DiffNote
.
name
,
image_path:
blob_raw_
path
,
alt:
diff_file
.
new_path
}
=
render
partial:
"projects/diffs/image_diff_frame"
,
locals:
{
class_name:
"added js-image-frame
#{
class_name
}
"
,
position:
position
,
note_type:
DiffNote
.
name
,
image_path:
blob_raw_
url
,
alt:
diff_file
.
new_path
}
.controls
.controls
.transparent
.transparent
.drag-track
.drag-track
...
...
app/views/projects/diffs/_single_image_diff.html.haml
View file @
e8d0d6ba
-
blob
=
diff_file
.
blob
-
blob
=
diff_file
.
blob
-
old_blob
=
diff_file
.
old_blob
-
old_blob
=
diff_file
.
old_blob
-
blob_raw_
path
=
diff_file_blob_raw_path
(
diff_file
)
-
blob_raw_
url
=
diff_file_blob_raw_url
(
diff_file
)
-
old_blob_raw_
path
=
diff_file_old_blob_raw_path
(
diff_file
)
-
old_blob_raw_
url
=
diff_file_old_blob_raw_url
(
diff_file
)
-
click_to_comment
=
local_assigns
.
fetch
(
:click_to_comment
,
true
)
-
click_to_comment
=
local_assigns
.
fetch
(
:click_to_comment
,
true
)
-
diff_view_data
=
local_assigns
.
fetch
(
:diff_view_data
,
''
)
-
diff_view_data
=
local_assigns
.
fetch
(
:diff_view_data
,
''
)
-
class_name
=
''
-
class_name
=
''
...
@@ -12,5 +12,5 @@
...
@@ -12,5 +12,5 @@
.image.js-single-image
{
data:
diff_view_data
}
.image.js-single-image
{
data:
diff_view_data
}
.wrap
.wrap
-
single_class_name
=
diff_file
.
deleted_file?
?
'deleted'
:
'added'
-
single_class_name
=
diff_file
.
deleted_file?
?
'deleted'
:
'added'
=
render
partial:
"projects/diffs/image_diff_frame"
,
locals:
{
class_name:
"
#{
single_class_name
}
#{
class_name
}
js-image-frame"
,
position:
position
,
note_type:
DiffNote
.
name
,
image_path:
blob_raw_
path
,
alt:
diff_file
.
file_path
}
=
render
partial:
"projects/diffs/image_diff_frame"
,
locals:
{
class_name:
"
#{
single_class_name
}
#{
class_name
}
js-image-frame"
,
position:
position
,
note_type:
DiffNote
.
name
,
image_path:
blob_raw_
url
,
alt:
diff_file
.
file_path
}
%p
.image-info
=
number_to_human_size
(
blob
.
size
)
%p
.image-info
=
number_to_human_size
(
blob
.
size
)
changelogs/unreleased/dm-image-blob-diff-full-url.yml
0 → 100644
View file @
e8d0d6ba
---
title
:
Use app host instead of asset host when rendering image blob or diff
merge_request
:
author
:
type
:
fixed
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment