Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
iv
gitlab-workhorse
Commits
5ae1356e
Commit
5ae1356e
authored
9 years ago
by
Kamil Trzcinski
Browse files
Options
Download
Email Patches
Plain Diff
Use proper quotes escaping for DownloadArtifact method
Uses escaper from mime/multipart/writer.go.
parent
e0a2ea65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
internal/artifacts/artifact_download.go
internal/artifacts/artifact_download.go
+3
-1
internal/artifacts/escape_quotes.go
internal/artifacts/escape_quotes.go
+10
-0
No files found.
internal/artifacts/artifact_download.go
View file @
5ae1356e
...
...
@@ -58,10 +58,12 @@ func unpackFileFromZip(archiveFileName, fileName string, headers http.Header, ou
}
defer
reader
.
Close
()
basename
:=
filepath
.
Base
(
fileName
)
// Write http headers about the file
headers
.
Set
(
"Content-Length"
,
strconv
.
FormatInt
(
int64
(
file
.
UncompressedSize64
),
10
))
headers
.
Set
(
"Content-Type"
,
detectFileContentType
(
file
.
Name
))
headers
.
Set
(
"Content-Disposition"
,
"attachment; filename=
\"
"
+
filepath
.
Base
(
file
.
N
ame
)
+
"
\"
"
)
headers
.
Set
(
"Content-Disposition"
,
"attachment; filename=
\"
"
+
escapeQuotes
(
basen
ame
)
+
"
\"
"
)
// Copy file body to client
_
,
err
=
io
.
Copy
(
output
,
reader
)
...
...
This diff is collapsed.
Click to expand it.
internal/artifacts/escape_quotes.go
0 → 100644
View file @
5ae1356e
package
artifacts
import
"strings"
// taken from mime/multipart/writer.go
var
quoteEscaper
=
strings
.
NewReplacer
(
"
\\
"
,
"
\\\\
"
,
`"`
,
"
\\\"
"
)
func
escapeQuotes
(
s
string
)
string
{
return
quoteEscaper
.
Replace
(
s
)
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment