Project

General

Profile

Actions

Defect #16881

closed

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

Added by qu al over 10 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Toshi MARUYAMA
Category:
SCM
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

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

Files

git_adapter.rb.patch (1.14 KB) git_adapter.rb.patch qu al, 2014-05-14 05:40
git_adapter.rb.patch (1.15 KB) git_adapter.rb.patch Patch for Redmine 3.0 Tobias Fischer, 2015-06-03 19:43
branches.png (50.4 KB) branches.png Toshi MARUYAMA, 2019-04-30 10:34
log.txt (1.06 KB) log.txt Toshi MARUYAMA, 2019-04-30 10:34
branch-click.png (66.2 KB) branch-click.png Toshi MARUYAMA, 2019-04-30 10:34
tags.png (49.1 KB) tags.png Toshi MARUYAMA, 2019-04-30 10:34

Related issues

Related to Redmine - Patch #30827: git tags can't handle utf-8Closed

Actions
Has duplicate Redmine - Defect #21141: Git tags and branches need to be UTF-8 encodedClosed

Actions
Actions #1

Updated by qu al over 10 years ago

sorry, I forgot to attach the patch.

Actions #2

Updated by Toshi MARUYAMA over 10 years ago

  • Assignee set to Toshi MARUYAMA
Actions #3

Updated by Tobias Fischer about 10 years ago

This also happens with 2.5.2.stable and I can confirm that the patch provided by "qu al" works fine.

Actions #4

Updated by Tobias Fischer almost 10 years ago

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.

Actions #5

Updated by Toshi MARUYAMA almost 10 years ago

git_adapter.rb.patch cannot be accepted because it hard-code "UTF-8".
Redmine supports any encondings.
It needs more works.

Actions #6

Updated by Toshi MARUYAMA almost 10 years ago

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.

Actions #7

Updated by Jonathan Wiens almost 10 years ago

Same problem here ...


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'

When can we expect this issue to be resolved?

Actions #8

Updated by Toshi MARUYAMA almost 10 years ago

Jonathan Wiens wrote:

When can we expect this issue to be resolved?

git_adapter.rb.patch needs supporting any encoding and tests.

Actions #9

Updated by Jonathan Wiens over 9 years ago

Toshi MARUYAMA wrote:

Jonathan Wiens wrote:

When can we expect this issue to be resolved?

git_adapter.rb.patch needs supporting any encoding and tests.

Can someone do it?

Actions #10

Updated by Tobias Fischer over 9 years ago

Attached patch is for Redmine 3.0 (3.0.3 to be precise).
No further tests. It just works™ for me...

Actions #11

Updated by Toshi MARUYAMA about 9 years ago

  • Has duplicate Defect #21141: Git tags and branches need to be UTF-8 encoded added
Actions #12

Updated by Toshi MARUYAMA about 9 years ago

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.

Actions #13

Updated by Holger Just about 9 years ago

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.

Actions #14

Updated by Kra Rom over 6 years ago

I will give this ticket a bump.

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

My Environment:

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
  ...

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.

?

Actions #15

Updated by Go MAEDA almost 6 years ago

  • Related to Patch #30827: git tags can't handle utf-8 added
Actions #16

Updated by Toshi MARUYAMA over 5 years ago

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

Actions

Also available in: Atom PDF