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
b07da07c
Commit
b07da07c
authored
Apr 18, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just enforce the output encoding for Ansi2html
Fixes
https://sentry.gitlap.com/gitlab/gitlabcom/issues/27545/
parent
ec9f6180
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
12 deletions
+24
-12
lib/ci/ansi2html.rb
lib/ci/ansi2html.rb
+1
-1
lib/gitlab/ci/trace/stream.rb
lib/gitlab/ci/trace/stream.rb
+3
-10
spec/lib/gitlab/ci/trace/stream_spec.rb
spec/lib/gitlab/ci/trace/stream_spec.rb
+20
-1
No files found.
lib/ci/ansi2html.rb
View file @
b07da07c
...
@@ -172,7 +172,7 @@ module Ci
...
@@ -172,7 +172,7 @@ module Ci
close_open_tags
()
close_open_tags
()
OpenStruct
.
new
(
OpenStruct
.
new
(
html:
@out
,
html:
@out
.
force_encoding
(
Encoding
.
default_external
)
,
state:
state
,
state:
state
,
append:
append
,
append:
append
,
truncated:
truncated
,
truncated:
truncated
,
...
...
lib/gitlab/ci/trace/stream.rb
View file @
b07da07c
...
@@ -14,14 +14,7 @@ module Gitlab
...
@@ -14,14 +14,7 @@ module Gitlab
def
initialize
def
initialize
@stream
=
yield
@stream
=
yield
if
@stream
@stream
.
binmode
if
@stream
@stream
.
binmode
# Ci::Ansi2html::Converter would read from @stream directly,
# using @stream.each_line to be specific. It's safe to set
# the encoding here because IO#seek(bytes) and IO#read(bytes)
# are not characters based, so encoding doesn't matter to them.
@stream
.
set_encoding
(
Encoding
.
default_external
)
end
end
end
def
valid?
def
valid?
...
@@ -68,8 +61,8 @@ module Gitlab
...
@@ -68,8 +61,8 @@ module Gitlab
def
html
(
last_lines:
nil
)
def
html
(
last_lines:
nil
)
text
=
raw
(
last_lines:
last_lines
)
text
=
raw
(
last_lines:
last_lines
)
stream
=
StringIO
.
new
(
text
)
buffer
=
StringIO
.
new
(
text
)
::
Ci
::
Ansi2html
.
convert
(
stream
).
html
::
Ci
::
Ansi2html
.
convert
(
buffer
).
html
end
end
def
extract_coverage
(
regex
)
def
extract_coverage
(
regex
)
...
...
spec/lib/gitlab/ci/trace/stream_spec.rb
View file @
b07da07c
...
@@ -71,10 +71,18 @@ describe Gitlab::Ci::Trace::Stream do
...
@@ -71,10 +71,18 @@ describe Gitlab::Ci::Trace::Stream do
end
end
describe
'#append'
do
describe
'#append'
do
let
(
:tempfile
)
{
Tempfile
.
new
}
let
(
:stream
)
do
let
(
:stream
)
do
described_class
.
new
do
described_class
.
new
do
StringIO
.
new
(
"12345678"
)
tempfile
.
write
(
"12345678"
)
tempfile
.
rewind
tempfile
end
end
end
after
do
tempfile
.
unlink
end
end
it
"truncates and append content"
do
it
"truncates and append content"
do
...
@@ -84,6 +92,17 @@ describe Gitlab::Ci::Trace::Stream do
...
@@ -84,6 +92,17 @@ describe Gitlab::Ci::Trace::Stream do
expect
(
stream
.
size
).
to
eq
(
6
)
expect
(
stream
.
size
).
to
eq
(
6
)
expect
(
stream
.
raw
).
to
eq
(
"123489"
)
expect
(
stream
.
raw
).
to
eq
(
"123489"
)
end
end
it
'appends in binary mode'
do
'😺'
.
force_encoding
(
'ASCII-8BIT'
).
each_char
.
with_index
do
|
byte
,
offset
|
stream
.
append
(
byte
,
offset
)
end
stream
.
seek
(
0
)
expect
(
stream
.
size
).
to
eq
(
4
)
expect
(
stream
.
raw
).
to
eq
(
'😺'
)
end
end
end
describe
'#set'
do
describe
'#set'
do
...
...
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