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
1d35b844
Commit
1d35b844
authored
Jun 30, 2021
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix wiki encoding error creating event
Changelog: fixed
parent
5696f591
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
app/services/git/wiki_push_service/change.rb
app/services/git/wiki_push_service/change.rb
+2
-1
spec/services/git/wiki_push_service_spec.rb
spec/services/git/wiki_push_service_spec.rb
+23
-2
No files found.
app/services/git/wiki_push_service/change.rb
View file @
1d35b844
...
@@ -66,7 +66,8 @@ module Git
...
@@ -66,7 +66,8 @@ module Git
def
strip_extension
(
filename
)
def
strip_extension
(
filename
)
return
unless
filename
return
unless
filename
File
.
basename
(
filename
,
File
.
extname
(
filename
))
encoded_filename
=
Gitlab
::
EncodingHelper
.
encode_utf8
(
filename
.
dup
)
File
.
basename
(
encoded_filename
,
File
.
extname
(
encoded_filename
))
end
end
end
end
end
end
...
...
spec/services/git/wiki_push_service_spec.rb
View file @
1d35b844
...
@@ -64,6 +64,26 @@ RSpec.describe Git::WikiPushService, services: true do
...
@@ -64,6 +64,26 @@ RSpec.describe Git::WikiPushService, services: true do
expect
(
Event
.
last
(
count
).
pluck
(
:action
)).
to
match_array
(
Event
::
WIKI_ACTIONS
.
map
(
&
:to_s
))
expect
(
Event
.
last
(
count
).
pluck
(
:action
)).
to
match_array
(
Event
::
WIKI_ACTIONS
.
map
(
&
:to_s
))
end
end
context
'when wiki_page slug is not UTF-8 '
do
let
(
:binary_title
)
{
Gitlab
::
EncodingHelper
.
encode_binary
(
'编码'
)
}
def
run_service
wiki_page
=
create
(
:wiki_page
,
wiki:
wiki
,
title:
"
#{
binary_title
}
'foo'"
)
process_changes
do
# Test that new_path is converted to UTF-8
create
(
:wiki_page
,
wiki:
wiki
,
title:
binary_title
)
# Test that old_path is also is converted to UTF-8
update_page
(
wiki_page
.
title
,
'foo'
)
end
end
it
'does not raise an error'
do
expect
{
run_service
}.
not_to
raise_error
end
end
end
end
context
'two pages have been created'
do
context
'two pages have been created'
do
...
@@ -345,9 +365,10 @@ RSpec.describe Git::WikiPushService, services: true do
...
@@ -345,9 +365,10 @@ RSpec.describe Git::WikiPushService, services: true do
::
Wikis
::
CreateAttachmentService
.
new
(
container:
wiki
.
container
,
current_user:
current_user
,
params:
params
).
execute
::
Wikis
::
CreateAttachmentService
.
new
(
container:
wiki
.
container
,
current_user:
current_user
,
params:
params
).
execute
end
end
def
update_page
(
title
)
def
update_page
(
title
,
new_title
=
nil
)
new_title
=
title
unless
new_title
.
present?
page
=
git_wiki
.
page
(
title:
title
)
page
=
git_wiki
.
page
(
title:
title
)
git_wiki
.
update_page
(
page
.
path
,
title
,
'markdown'
,
'Hey'
,
commit_details
)
git_wiki
.
update_page
(
page
.
path
,
new_
title
,
'markdown'
,
'Hey'
,
commit_details
)
end
end
def
delete_page
(
page
)
def
delete_page
(
page
)
...
...
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