Defect #16881

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

Added by qu al over 5 years ago. Updated 8 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Toshi MARUYAMA% Done:

0%

Category:SCM
Target version:4.1.0
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

git_adapter.rb.patch Magnifier (1.14 KB) qu al, 2014-05-14 05:40

git_adapter.rb.patch Magnifier - Patch for Redmine 3.0 (1.15 KB) Tobias Fischer, 2015-06-03 19:43

branches.png (50.4 KB) Toshi MARUYAMA, 2019-04-30 10:34

log.txt Magnifier (1.06 KB) Toshi MARUYAMA, 2019-04-30 10:34

branch-click.png (66.2 KB) Toshi MARUYAMA, 2019-04-30 10:34

tags.png (49.1 KB) Toshi MARUYAMA, 2019-04-30 10:34


Related issues

Related to Redmine - Patch #30827: git tags can't handle utf-8 Closed
Duplicated by Redmine - Defect #21141: Git tags and branches need to be UTF-8 encoded Closed

Associated revisions

Revision 13135
Added by Toshi MARUYAMA over 5 years ago

add :environment to test:scm:setup:create_dir and test:scm:update rake tasks (#16881)

Revision 13136
Added by Toshi MARUYAMA over 5 years ago

split method for scm test repository extracting (#16881)

Revision 18039
Added by Toshi MARUYAMA 8 months ago

scm: git: add new two latin1 branches to test repository (#16881)

Revision 18040
Added by Toshi MARUYAMA 8 months ago

scm: git: add new one latin1 tag to test repository (#16881)

Revision 18042
Added by Toshi MARUYAMA 8 months ago

scm: git: fix non ascii branch and tag browsing (#16881)

History

#1 Updated by qu al over 5 years ago

sorry, I forgot to attach the patch.

#2 Updated by Toshi MARUYAMA over 5 years ago

  • Assignee set to Toshi MARUYAMA

#3 Updated by Tobias Fischer about 5 years ago

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

#4 Updated by Tobias Fischer almost 5 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.

#5 Updated by Toshi MARUYAMA almost 5 years ago

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

#6 Updated by Toshi MARUYAMA almost 5 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.

#7 Updated by Jonathan Wiens almost 5 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?

#8 Updated by Toshi MARUYAMA almost 5 years ago

Jonathan Wiens wrote:

When can we expect this issue to be resolved?

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

#9 Updated by Jonathan Wiens almost 5 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?

#10 Updated by Tobias Fischer over 4 years ago

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

#11 Updated by Toshi MARUYAMA about 4 years ago

  • Duplicated by Defect #21141: Git tags and branches need to be UTF-8 encoded added

#12 Updated by Toshi MARUYAMA about 4 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.

#13 Updated by Holger Just about 4 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.

#14 Updated by Kra Rom almost 2 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.

?

#15 Updated by Go MAEDA 10 months ago

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

#16 Updated by Toshi MARUYAMA 8 months ago

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

Also available in: Atom PDF