gitit icon indicating copy to clipboard operation
gitit copied to clipboard

Crash on non ascii discription of changes

Open rshadow opened this issue 11 years ago • 9 comments

I try to save changes with some utf8 comment, but got message:

Server error: git: recoverEncode: invalid argument (invalid character)

Comment is "Тестовое сообщение" on Russian. All comment in ASCII work good.

gitit 0.10.0.1 git 1.7.10.4 x86_64 GNU/Linux

rshadow avatar Dec 25 '13 21:12 rshadow

I have the same problem … the innocuous UTF-8 character “…” triggered it for me. I'm using gitit 0.9-1ubuntu1 and git 1:1.7.9.5-1, both of ubuntu 12.04 x86_64.

gallafent avatar Feb 21 '14 13:02 gallafent

I couldn't reproduce this. Make sure your system is running with UTF-8 locale.

locale should report UTF-8.

jgm avatar May 21 '14 02:05 jgm

@jgm And I can reproduce this.

Cysioland avatar Sep 11 '15 15:09 Cysioland

What does locale say?

+++ Cysioland [Sep 11 15 08:06 ]:

[1]@jgm And I can reproduce this.

— Reply to this email directly or [2]view it on GitHub.

References

  1. https://github.com/jgm
  2. https://github.com/jgm/gitit/issues/393#issuecomment-139570104

jgm avatar Sep 11 '15 16:09 jgm

I can reproduce:

# cat /proc/27066/environ | tr '\0' '\n'
LANG=de_DE.UTF-8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOME=/home/gitit
LOGNAME=gitit
USER=gitit
SHELL=/bin/bash

I had a German umlaut (ü in this case) and got the error:

Happstack 7.6.1

Something went wrong here
Internal server error
Everything has stopped

The error was "git: recoverEncode: invalid argument (invalid character)"

Profpatsch avatar Jun 16 '20 14:06 Profpatsch

I was able to fix by using C.UTF-8, though since we are committing these from a webform, we should be able to fix to UTF-8 by default, right? Then it becomes independent of the users setting the right locale.

For reference, the system has these locales installed:

# localectl list-locales
C.UTF-8
de_DE.utf8
en_US.utf8

The lowercase .utf8 might have confused something.

Profpatsch avatar Jun 16 '20 15:06 Profpatsch

Maybe it’s helpful to some, our gitit is run from this systemd service file:

# systemctl cat gitit                                                                                   
# /etc/systemd/system/gitit.service
[Unit]
Description=OpenLab custom gitit wiki
After=network.target

[Service]
ExecStart=/home/gitit/gitit-0.13.0.0/bin/gitit --listen 127.0.0.1 --port 5001 +RTS -I0 -RTS
WorkingDirectory=/home/gitit/gitit-db
User=gitit
Group=users
Restart=on-abort
Environment="LC_ALL=C.UTF-8"

[Install]
WantedBy=multi-user.target

Profpatsch avatar Jun 16 '20 15:06 Profpatsch

The ~~manual~~ README.markdown does say

So you should make sure that you are using a UTF-8 locale when running gitit. (To check this, type locale.)

jgm avatar Jun 16 '20 15:06 jgm

It ought to be possible to set LANG in the process running the git commands, but this would have to be done in the filestore library (see the local function runGitCommandWithEnv in Git.hs there). It would mean a change in behavior for that library, so maybe a bit risky.

jgm avatar Jun 16 '20 15:06 jgm