Defect #25846

Repository directory listing: ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8)

Added by Marc Vollmer 8 months ago. Updated 3 days ago.

Status:Needs feedbackStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:SCM
Target version:-
Resolution: Affected version:3.3.3

Description

Hello,

we have added 4 repositories (Git Remote) as projectarchvies to redmine.
When we open those repositories in the projectarchive view 3 of them work, one gives the following error:

Started GET "/projects/XXX/repository/XXX" for XXX.XXX.XXX.XXX at 2017-05-15 10:10:00 +0200
Processing by RepositoriesController#show as HTML
  Parameters: {"id"=>"XXX", "repository_id"=>"XXX"}
  Current user: XXX (id=135)
  Rendered repositories/_navigation.html.erb (38.5ms)
  Rendered repositories/_breadcrumbs.html.erb (0.9ms)
  Rendered repositories/_dir_list_content.html.erb (10.4ms)
  Rendered repositories/_dir_list.html.erb (10.9ms)
  Rendered repositories/show.html.erb within layouts/base (53.8ms)
Completed 500 Internal Server Error in 168ms (ActiveRecord: 3.5ms)

ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8):
     8:                :locals => { :path => @path, :kind => 'dir', :revision => @rev } %></h2>
     9:
    10: <% if !@entries.nil? && authorize_for('repositories', 'browse') %>
    11:   <%= render :partial => 'dir_list' %>
    12: <% end %>
    13:
    14: <%= render_properties(@properties) %>
  app/views/repositories/show.html.erb:11:in `_app_views_repositories_show_html_erb__1302325350339252382_70155590060320'
  app/controllers/repositories_controller.rb:125:in `show'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'

My first guess was that theres a directory of file in the repository that has an invalid char as a name, so I wrote a little script to check all filenames against a regex and we just found a file containing a ~ in the name.

We had this repository working before, so the file must be added in the last 1 to 2 month but the file containing the ~ was added 2 years ago.

I already tried to re add the repository with no success and other repositories I added as a test also work.

Thanks for your help in advance!

2.png (10.8 KB) Toshi MARUYAMA, 2017-05-15 12:27

1.png (12.7 KB) Toshi MARUYAMA, 2017-05-15 12:27

History

#1 Updated by Toshi MARUYAMA 8 months ago

  • File 2.png added
  • File 1.png added
  • Status changed from New to Needs feedback

I cannot reproduce.


$ rpm -q git
git-1.8.3.1-6.el7_2.1.x86_64

#2 Updated by Marc Vollmer 8 months ago

We have multiple repositories (4 configured) 3 work 1 not, as stated it's definitely not the ~ because it's been there for too long and theres also one working repository that also has a ~ in a file name.

We checked all files and directories against the following regex and they all match: ^[a-zA-Z0-9._\-$ ~]+$
So no files with unusual chars in the name.

As a reference the git version:

# zypper if git-core
Refreshing service 'SUSE_Linux_Enterprise_Server_12_SP2_x86_64'.
Refreshing service 'SUSE_Linux_Enterprise_Software_Development_Kit_12_SP2_x86_64'.
Loading repository data...
Reading installed packages...

Information for package git-core:
---------------------------------
Repository     : SLES12-SP2-Updates
Name           : git-core
Version        : 2.12.0-23.1
Arch           : x86_64
Vendor         : SUSE LLC <https://www.suse.com/>
Support Level  : Level 3
Installed Size : 29.5 MiB
Installed      : Yes
Status         : out-of-date (version 1.8.5.6-18.1 installed)
Summary        : Core git tools
Description    :
    Git is a fast, scalable, distributed revision control system with an
    unusually rich command set that provides both high-level operations and
    full access to internals.

    These are the core tools with minimal dependencies.

Commits with Ticket ID's are referenced in tickets, so scanning also works.

#3 Updated by Luc Lalonde 4 months ago

We're also seeing this error:

ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8):
    27:                    :id => 'tag' %>
    28:   <% end -%>
    29: 
    30:   <% if @repository.supports_all_revisions? %>
    31:     | <%= l(:label_revision) %>: 
    32:     <%= text_field_tag 'rev', @rev, :size => 8 %>
    33:   <% end %>
  app/views/repositories/_navigation.html.erb:30:in `block in _app_views_repositories__navigation_html_erb__965151315351232331_69898529566340'
  app/views/repositories/_navigation.html.erb:9:in `_app_views_repositories__navigation_html_erb__965151315351232331_69898529566340'
  app/views/repositories/show.html.erb:4:in `_app_views_repositories_show_html_erb___2125122647801616403_69898529468540'
  app/controllers/repositories_controller.rb:125:in `show'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'

This patch solves the problem:

[root@githost adapters]# pwd
/var/www/redmine/lib/redmine/scm/adapters
[root@githost adapters]# diff git_adapter.rb git_adapter.rb.bak2017-10-05 
89d88
<             bran.force_encoding("UTF-8") if bran.respond_to?(:force_encoding)
103,108c102
< #            @tags = io.readlines.sort!.map{|t| t.strip}
<              @tags = io.readlines.sort!.map do |tag|
<                        tag = tag.strip
<                        tag.force_encoding("UTF-8") if tag.respond_to?(:force_encoding)
<                        tag
<                      end
---
>             @tags = io.readlines.sort!.map{|t| t.strip}

Here's the link for the original reference:

https://stackoverflow.com/questions/42804760/error-in-repository-view-redmin-actionviewtemplateerror-incompatible-charac

Hope this can lea

#4 Updated by Luc Lalonde 4 months ago

Forgot these details:

Environment:
  Redmine version                3.3.3.stable
  Ruby version                   2.3.1-p112 (2016-04-26) [x86_64-linux]
  Rails version                  4.2.7.1
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.7.14
  Git                            1.8.3.1
  Filesystem                     
Redmine plugins:
  redmine_ldap_sync              2.0.8.devel.gf916e6574e
  timesheet                      0.7.0

#5 Updated by leonid terekhov 3 days ago

Luc Lalonde wrote:

We're also seeing this error:

[...]

This patch solves the problem:

[...]

Here's the link for the original reference:

https://stackoverflow.com/questions/42804760/error-in-repository-view-redmin-actionviewtemplateerror-incompatible-charac

Hope this can lea

Thank you! It works for me.

Also available in: Atom PDF