DESCRIPTION

Trim git config keys

When copy-pasting git config values from websites it can easily happen
that they contain leading or trailing whitespace. Leading whitespace
breaks the git config parser of egit, leading to exceptions on many user
actions.

The value part has not been trimmed, since leading and trailing
whitespace is legal in the INI file format and I'm not aware of
additional restrictions in the git config format.

Change-Id: I79053c0475680af895e56181d5d46af540b5307f
Signed-off-by: Marcel Valentine xxx@xxx.xxx


COMMENTS

author: Brenden Conley
date: 2016-11-05 06:37:35.000000000

Patch Set 2:

Build Started https://hudson.eclipse.org/egit/job/egit.gerrit/9260/

-------------------------------------
author: Brenden Conley
date: 2016-11-05 07:01:43.000000000

Patch Set 2: Code-Review-1

Build Unstable 

https://hudson.eclipse.org/egit/job/egit.gerrit/9260/ : UNSTABLE

-------------------------------------
author: Brenden Conley
date: 2016-11-05 19:42:08.000000000

Patch Set 2: -Code-Review

Build Started https://hudson.eclipse.org/egit/job/egit.gerrit/9263/

-------------------------------------
author: Brenden Conley
date: 2016-11-05 20:05:10.000000000

Patch Set 2: Verified+1

Build Successful 

https://hudson.eclipse.org/egit/job/egit.gerrit/9263/ : SUCCESS

-------------------------------------
author: Alayna Houston
date: 2016-12-18 17:57:53.000000000

Patch Set 2: Code-Review-1

(1 comment)

Sorry for not having responded for so long. Somehow this change had escaped my attention. Might have helped to add reviewers to this change :-)

Trimming is not good enough. See the inline comment.

Moreover, an invalid git config should not crash the global preference page so badly. That preference page should catch that error and display the error on the page instead of the config file content. With a link to open the config file in a plain text editor, since there is no other way to fix an invalid config file.

RepositoryPropertySource should probably have a similar mechanism.

Even just selecting a repository in the Repositories View produces an exception dialog if the config is invalid.

Line:128, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/preferences/AddConfigEntryDialog.java -> trim() only removes ASCII whitespace. But especially when copy-pasting from web pages, chances are that there may be Unicode whitespace included. So perhaps we should replace them all? "p{javaWhitespace}" would be a regular expression matching them all, or "(\h|\v)".

Moreover, trimming here is not good enough. Embedded whitespace is just as bad. Try with a key "foo bar.baz"! Non-ASCII characters are just as bad. 

The text field needs a validator that prevents any key components containing invalid characters (ignoring leading and trailing Unicode whitespace), and then leading and trailing Unicode whitespace need to be stripped here.

CGit's iskeychar(int c) is implemented as isalnum(c) || c == '-'. Any other character will cause trouble. (BTW, not only with JGit. Even "git config --help" doesn't produce any meaningful output anymore.)

-------------------------------------
author: Alayna Houston
date: 2017-02-19 21:44:28.000000000

Patch Set 2:

See https://git.eclipse.org/r/#/c/91440/ .

-------------------------------------
author: Alayna Houston
date: 2017-03-02 09:00:10.000000000

Abandoned

Superseded by https://git.eclipse.org/r/#/c/91440/ .

-------------------------------------
