プロジェクト

全般

プロフィール

Vote #75220

完了

Git: repository page crashes when non-ascii character in tag or branch name

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
SCM_3
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
3
version_id:
127
issue_org_id:
16881
author_id:
101640
assigned_to_id:
11192
comments:
16
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

If tag or branch name in git contains non-ascii character(ex."あ","い",etc.), Repository page crashes with the following messages in the production.log:

Started GET "/redmine/projects/XXX-000000/repository/git" for 127.0.0.1 at 2014-05-13 09:04:03 +0900
Processing by RepositoriesController#show as HTML
  Parameters: {"id"=>"XXX-000000", "repository_id"=>"git"}
  Current user: YYYYY (id=6)
  Rendered repositories/_navigation.html.erb (93.8ms)
  Rendered repositories/show.html.erb within layouts/base (93.8ms)
Completed 500 Internal Server Error in 812.5ms

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):
  app/views/repositories/_navigation.html.erb:24:in `block in _app_views_repositories__navigation_html_erb__875303464_30435480'
  app/views/repositories/_navigation.html.erb:13:in `_app_views_repositories__navigation_html_erb__875303464_30435480'
  app/views/repositories/show.html.erb:4:in `_app_views_repositories_show_html_erb___1026796241_22987116'
  app/controllers/repositories_controller.rb:125:in `show'

Atatched patch fixed the problem for me, but I'm not sure if it is a correct solution.

Environment:
  Redmine version                2.4.1.stable
  Ruby version                   1.9.3-p231 (2012-05-25) [i386-mingw32]
  Rails version                  3.2.16
  Environment                    production
  Database adapter               Mysql2
SCM:
  Git                            1.8.3

journals

sorry, I forgot to attach the patch.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
This also happens with 2.5.2.stable and I can confirm that the patch provided by "qu al" works fine.
--------------------------------------------------------------------------------
The UTF8 patch by Jean-Philippe in #13520 (r13807) added in v2.6.1 didn't fix this problem.

It still appears in v2.6.1.stable.13876 and I can confirm that the patch provided by "qu al" still works.
--------------------------------------------------------------------------------
git_adapter.rb.patch cannot be accepted because it hard-code "UTF-8".
Redmine supports any encondings.
It needs more works.
--------------------------------------------------------------------------------
Tobias Fischer wrote:
> The UTF8 patch by Jean-Philippe in #13520 (r13807) added in v2.6.1 didn't fix this problem.

It is not related.

--------------------------------------------------------------------------------
Same problem here ...

<pre>

Processing by RepositoriesController#show as HTML
Parameters: {"id"=>"development"}
Current user: jonw (id=4)
Rendered repositories/_navigation.html.erb (175.1ms)
Rendered repositories/_breadcrumbs.html.erb (2.8ms)
Rendered repositories/_dir_list_content.html.erb (170.9ms)
Rendered repositories/_dir_list.html.erb (172.4ms)
Rendered repositories/_revision_graph.html.erb (4.9ms)
Rendered repositories/_revisions.html.erb (207.9ms)
Rendered repositories/show.html.erb within layouts/base (575.0ms)
Completed 500 Internal Server Error in 5821.6ms

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):
55: <%= yield :sidebar %>
56: <%= view_layouts_base_sidebar_hook_response %>
57: </div>
58:
59: <div id="content">
60: <%= render_flash_messages %>
61: <%= yield %>
app/views/layouts/base.html.erb:58:in `_app_views_layouts_base_html_erb___4435422814910722795_44338100'
app/controllers/repositories_controller.rb:125:in `show'
</pre>

When can we expect this issue to be resolved?
--------------------------------------------------------------------------------
Jonathan Wiens wrote:
> When can we expect this issue to be resolved?

attachment:git_adapter.rb.patch needs supporting any encoding and tests.
--------------------------------------------------------------------------------
Toshi MARUYAMA wrote:
> Jonathan Wiens wrote:
> > When can we expect this issue to be resolved?
>
> attachment:git_adapter.rb.patch needs supporting any encoding and tests.

Can someone do it?
--------------------------------------------------------------------------------
Attached patch is for Redmine 3.0 (3.0.3 to be precise).
No further tests. It just works™ for me...
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Mercurial test covers non ASCII tag and branch.
source:tags/3.1.1/test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb#L322

Git needs same test.
--------------------------------------------------------------------------------
While the proposed patch might not be 100% correct in all cases, it is still way better than just running into a hard error on rendering.

If you want to be better by detecting and rendering further encodings: fine. But by all means, please support the (at least) 80% case of UTF-8 branch names. For future work, you _could_ repurpose @@path_encoding@ (which defaults to UTF-8).

In fact, it is probably safe enough to just call @.force_encoding(@path_encoding)@ and call it a day. This is most probably safe as git stores the names of tags and branches in the filesystem anyway so the encoding of path names is probably the same as the encoding of the branch names.

Still, please commit one of the fixes. Even it it still breaks on some edge-cases, it is way better than what we have now.
--------------------------------------------------------------------------------
I will give this ticket a bump.

Error occurred in redmine 3.3.3.
Patch from Tobias Fischer worked.

My Environment:

<pre>
Environment:
Redmine version 3.3.3.stable
Ruby version 2.2.7-p470 (2017-03-28) [x86_64-linux]
Rails version 4.2.7.1
Environment production
Database adapter Mysql2
SCM:
Subversion 1.9.5
Git 2.11.0
Filesystem
GitRemote 2.11.0
Redmine plugins:
redmine_git_remote 0.0.1
scrum 0.17.0
...
</pre>

So:
> Still, please commit one of the fixes. Even it it still breaks on some edge-cases, it is way better than what we have now.
?
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
I implemented git tags and branches encoding in r18039, r18040, r18042.
Attachments are utf8 test repository and its results.
--------------------------------------------------------------------------------


related_issues

relates,Closed,30827,git tags can't handle utf-8
duplicates,Closed,21141,Git tags and branches need to be UTF-8 encoded

Admin Redmine さんが3年以上前に更新

  • カテゴリSCM_3 にセット
  • 対象バージョン4.1.0_127 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0