Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
a09b9468c7c7
Commit
a09b9468
authored
Oct 20, 2017
by
Toon Claes
Browse files
URI decode Page-Title header to preserve UTF-8 characters
parent
8ee310e1503b
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/assets/javascripts/repo/helpers/repo_helper.js
View file @
a09b9468
...
...
@@ -95,7 +95,7 @@
return
Service
.
getContent
()
.
then
((
response
)
=>
{
const
data
=
response
.
data
;
if
(
response
.
headers
&&
response
.
headers
[
'
page-title
'
])
data
.
pageTitle
=
response
.
headers
[
'
page-title
'
];
if
(
response
.
headers
&&
response
.
headers
[
'
page-title
'
])
data
.
pageTitle
=
decodeURI
(
response
.
headers
[
'
page-title
'
]
)
;
if
(
response
.
headers
&&
response
.
headers
[
'
is-root
'
]
&&
!
Store
.
isInitialRoot
)
{
Store
.
isRoot
=
convertPermissionToBoolean
(
response
.
headers
[
'
is-root
'
]);
Store
.
isInitialRoot
=
Store
.
isRoot
;
...
...
app/controllers/application_controller.rb
View file @
a09b9468
...
...
@@ -349,6 +349,6 @@
def
set_page_title_header
# Per https://tools.ietf.org/html/rfc5987, headers need to be ISO-8859-1, not UTF-8
response
.
headers
[
'Page-Title'
]
=
page_title
(
'GitLab'
)
.
encode
(
'ISO-8859-1'
)
response
.
headers
[
'Page-Title'
]
=
URI
.
escape
(
page_title
(
'GitLab'
))
end
end
spec/controllers/application_controller_spec.rb
View file @
a09b9468
...
...
@@ -221,6 +221,20 @@
end
end
describe
'#set_page_title_header'
do
let
(
:controller
)
{
described_class
.
new
}
it
'URI encodes UTF-8 characters in the title'
do
response
=
double
(
headers:
{})
allow_any_instance_of
(
PageLayoutHelper
).
to
receive
(
:page_title
).
and_return
(
'€100 · GitLab'
)
allow
(
controller
).
to
receive
(
:response
).
and_return
(
response
)
controller
.
send
(
:set_page_title_header
)
expect
(
response
.
headers
[
'Page-Title'
]).
to
eq
(
'%E2%82%AC100%20%C2%B7%20GitLab'
)
end
end
context
'two-factor authentication'
do
let
(
:controller
)
{
described_class
.
new
}
...
...
Write
Preview
Supports
Markdown
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