@@ -25,6 +25,7 @@ import (
25
25
"code.gitea.io/gitea/modules/setting"
26
26
27
27
"github.com/dgrijalva/jwt-go"
28
+ "github.com/kballard/go-shellquote"
28
29
"github.com/unknwon/com"
29
30
"github.com/urfave/cli"
30
31
)
@@ -126,25 +127,35 @@ func runServ(c *cli.Context) error {
126
127
return nil
127
128
}
128
129
129
- verb , args := parseCmd (cmd )
130
+ words , err := shellquote .Split (cmd )
131
+ if err != nil {
132
+ fail ("Error parsing arguments" , "Failed to parse arguments: %v" , err )
133
+ }
134
+
135
+ if len (words ) < 2 {
136
+ fail ("Too few arguments" , "Too few arguments in cmd: %s" , cmd )
137
+ }
138
+
139
+ verb := words [0 ]
140
+ repoPath := words [1 ]
141
+ if repoPath [0 ] == '/' {
142
+ repoPath = repoPath [1 :]
143
+ }
130
144
131
145
var lfsVerb string
132
146
if verb == lfsAuthenticateVerb {
133
147
if ! setting .LFS .StartServer {
134
148
fail ("Unknown git command" , "LFS authentication request over SSH denied, LFS support is disabled" )
135
149
}
136
150
137
- argsSplit := strings .Split (args , " " )
138
- if len (argsSplit ) >= 2 {
139
- args = strings .TrimSpace (argsSplit [0 ])
140
- lfsVerb = strings .TrimSpace (argsSplit [1 ])
151
+ if len (words ) > 2 {
152
+ lfsVerb = words [2 ]
141
153
}
142
154
}
143
155
144
- repoPath := strings .ToLower (strings .Trim (args , "'" ))
145
156
rr := strings .SplitN (repoPath , "/" , 2 )
146
157
if len (rr ) != 2 {
147
- fail ("Invalid repository path" , "Invalid repository path: %v" , args )
158
+ fail ("Invalid repository path" , "Invalid repository path: %v" , repoPath )
148
159
}
149
160
150
161
username := strings .ToLower (rr [0 ])
0 commit comments