summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-11-15 01:59:21 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-11-15 01:59:21 -0500
commitb5ce8ccc734d73dcfe9f11f7aff46b158860f276 (patch)
tree085b6900ab6431473caca82c3067e6d19bc7251d
parentb2c0c37fe3c5b7bc5b762a62a3372de2b3b30538 (diff)
don't convert to CRLF when editing using the web form
-rw-r--r--got/view_blob.got1
-rw-r--r--src/edit/posthack.go3
2 files changed, 4 insertions, 0 deletions
diff --git a/got/view_blob.got b/got/view_blob.got
index 16d7ff1..0d7c80c 100644
--- a/got/view_blob.got
+++ b/got/view_blob.got
@@ -8,6 +8,7 @@
{{if istext .ctype}}
<form method="POST" enctype="multipart/form-data">
<input type="hidden" name="_method" value="PUT">
+ <input type="hidden" name="_body_decrlf" value="1">
<textarea name="_body">{{.content | html }}</textarea>
<label>
Description of change:
diff --git a/src/edit/posthack.go b/src/edit/posthack.go
index 9e4759e..fad692b 100644
--- a/src/edit/posthack.go
+++ b/src/edit/posthack.go
@@ -44,6 +44,9 @@ func PostHack(req *http.Request) {
req.MultipartForm = nil
} else if bodies := req.PostForm["_body"]; len(bodies) > 0 {
body := bodies[0]
+ if req.PostFormValue("_body_decrlf") != "" {
+ body = strings.Replace(body, "\r\n", "\n", -1)
+ }
req.Body = ioutil.NopCloser(strings.NewReader(body))
if req.Header.Get("Content-Length") != "" {
req.Header.Set("Content-Length", strconv.Itoa(len(body)))