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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
18fcdd36
Commit
18fcdd36
authored
Jul 06, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use jQuery to strip HTML from response
parent
01355138
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
10 deletions
+6
-10
app/assets/javascripts/geo_nodes.js
app/assets/javascripts/geo_nodes.js
+2
-1
app/services/geo/node_status_service.rb
app/services/geo/node_status_service.rb
+2
-7
spec/services/geo/node_status_service_spec.rb
spec/services/geo/node_status_service_spec.rb
+2
-2
No files found.
app/assets/javascripts/geo_nodes.js
View file @
18fcdd36
...
@@ -43,7 +43,8 @@ class GeoNodeStatus {
...
@@ -43,7 +43,8 @@ class GeoNodeStatus {
if
(
status
.
health
===
'
Healthy
'
)
{
if
(
status
.
health
===
'
Healthy
'
)
{
this
.
$health
.
html
(
''
);
this
.
$health
.
html
(
''
);
}
else
{
}
else
{
this
.
$health
.
html
(
`<code class="geo-health">
${
status
.
health
}
</code>`
);
const
strippedData
=
$
(
'
<div>
'
).
html
(
`
${
status
.
health
}
`
).
text
();
this
.
$health
.
html
(
`<code class="geo-health">
${
strippedData
}
</code>`
);
}
}
this
.
$status
.
show
();
this
.
$status
.
show
();
...
...
app/services/geo/node_status_service.rb
View file @
18fcdd36
module
Geo
module
Geo
class
NodeStatusService
class
NodeStatusService
include
ActionView
::
Helpers
::
SanitizeHelper
include
Gitlab
::
CurrentSettings
include
Gitlab
::
CurrentSettings
include
HTTParty
include
HTTParty
...
@@ -29,11 +28,11 @@ module Geo
...
@@ -29,11 +28,11 @@ module Geo
if
payload
.
is_a?
(
Hash
)
if
payload
.
is_a?
(
Hash
)
payload
[
'message'
]
payload
[
'message'
]
else
else
# The return value can be a giant blob of HTML; ignore it
''
''
end
end
summary
=
[
message
,
details
].
compact
.
join
(
"
\n
"
)
Array
([
message
,
details
].
compact
.
join
(
"
\n
"
))
[
sanitize
(
summary
)]
end
end
rescue
HTTParty
::
Error
,
Timeout
::
Error
,
SocketError
,
Errno
::
ECONNRESET
,
Errno
::
ECONNREFUSED
=>
e
rescue
HTTParty
::
Error
,
Timeout
::
Error
,
SocketError
,
Errno
::
ECONNRESET
,
Errno
::
ECONNREFUSED
=>
e
[
e
.
message
]
[
e
.
message
]
...
@@ -44,10 +43,6 @@ module Geo
...
@@ -44,10 +43,6 @@ module Geo
private
private
def
sanitize
(
message
)
ActionView
::
Base
.
full_sanitizer
.
sanitize
(
message
)
end
def
headers
def
headers
Gitlab
::
Geo
::
BaseRequest
.
new
.
headers
Gitlab
::
Geo
::
BaseRequest
.
new
.
headers
end
end
...
...
spec/services/geo/node_status_service_spec.rb
View file @
18fcdd36
...
@@ -11,11 +11,11 @@ describe Geo::NodeStatusService, services: true do
...
@@ -11,11 +11,11 @@ describe Geo::NodeStatusService, services: true do
end
end
describe
'#call'
do
describe
'#call'
do
it
'
strips tags from
a 401 response'
do
it
'
parses
a 401 response'
do
request
=
double
(
success?:
false
,
request
=
double
(
success?:
false
,
code:
401
,
code:
401
,
message:
'Unauthorized'
,
message:
'Unauthorized'
,
parsed_response:
{
'message'
=>
'
<html><h1>Test</h1></html>
'
}
)
parsed_response:
{
'message'
=>
'
Test
'
}
)
allow
(
described_class
).
to
receive
(
:get
).
and_return
(
request
)
allow
(
described_class
).
to
receive
(
:get
).
and_return
(
request
)
status
=
subject
.
call
(
secondary
)
status
=
subject
.
call
(
secondary
)
...
...
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