Skip to content
代码片段 群组 项目
未验证 提交 b936a1d3 编辑于 作者: Stan Hu's avatar Stan Hu
浏览文件

Ensure errors.css is interpreted as UTF-8 encoding

Since
https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/19096,
we've inlined the `errors.css` by directly including the Sprockets
assets into the HAML. This worked fine as long as the CSS file
remained as a plain ASCII file. However, the switch to the new CSS
pipeline with
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/144479 appears
to have introduced a single UTF-8 character. Since Sprockets loads the
asset via `File.binread`, the contents of this UTF-8 file is forced as
ASCII-8BIT. When this ASCII-8BIT string is combined with other UTF-8
characters, such as Chinese characters, the encoding fails with a 500
error: `incompatible character encodings: ASCII-8BIT and UTF-8
(Encoding::CompatibilityError)`.

To work around this issue, we force the encoding to UTF-8 to ensure
the error page can render.

Relates to
https://gitlab.com/gitlab-com/gl-infra/production/-/issues/17627

Changelog: fixed
上级 8c9b6b98
No related branches found
No related tags found
无相关合并请求
......@@ -4,7 +4,7 @@
%meta{ :content => "width=device-width, initial-scale=1", :name => "viewport" }
%title= yield(:title)
%style
= Rails.application.assets_manifest.find_sources('errors.css').first.to_s.html_safe
= Rails.application.assets_manifest.find_sources('errors.css').first.to_s.force_encoding('UTF-8').html_safe
%body
.page-container
= yield
......
......@@ -5,7 +5,7 @@
%title= yield(:title)
= stylesheet_link_tag 'application_utilities'
%style
= Rails.application.assets_manifest.find_sources('errors.css').first.to_s.html_safe
= Rails.application.assets_manifest.find_sources('errors.css').first.to_s.force_encoding('UTF-8').html_safe
:css
svg {
width: 280px;
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册