diff options
| author | Dmitry Gutov | 2016-06-22 21:20:06 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2016-06-22 21:20:23 +0300 |
| commit | a98aa02a5dbf079f7b4f3be5487a2f2b741d103d (patch) | |
| tree | c5753ff715b312835b4cf22fb17927371f55ba0e | |
| parent | ea512a7c2cd30206dd509b193c9faaba25640180 (diff) | |
| download | emacs-a98aa02a5dbf079f7b4f3be5487a2f2b741d103d.tar.gz emacs-a98aa02a5dbf079f7b4f3be5487a2f2b741d103d.zip | |
Error on multibyte characters in HTTP request
* lisp/url/url-http.el (url-http-create-request): Check the
constructed request in the end to verify that it does not contain
multibyte characters (bug#23750).
| -rw-r--r-- | lisp/url/url-http.el | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 5832e92c5a3..7156e6fa4ea 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el | |||
| @@ -275,19 +275,7 @@ request.") | |||
| 275 | ;; allows us to elide null lines directly, at the cost of making | 275 | ;; allows us to elide null lines directly, at the cost of making |
| 276 | ;; the layout less clear. | 276 | ;; the layout less clear. |
| 277 | (setq request | 277 | (setq request |
| 278 | ;; We used to concat directly, but if one of the strings happens | 278 | (concat |
| 279 | ;; to being multibyte (even if it only contains pure ASCII) then | ||
| 280 | ;; every string gets converted with `string-MAKE-multibyte' which | ||
| 281 | ;; turns the 127-255 codes into things like latin-1 accented chars | ||
| 282 | ;; (it would work right if it used `string-TO-multibyte' instead). | ||
| 283 | ;; So to avoid the problem we force every string to be unibyte. | ||
| 284 | (mapconcat | ||
| 285 | ;; FIXME: Instead of `string-AS-unibyte' we'd want | ||
| 286 | ;; `string-to-unibyte', so as to properly signal an error if one | ||
| 287 | ;; of the strings contains a multibyte char. | ||
| 288 | 'string-as-unibyte | ||
| 289 | (delq nil | ||
| 290 | (list | ||
| 291 | ;; The request | 279 | ;; The request |
| 292 | (or url-http-method "GET") " " | 280 | (or url-http-method "GET") " " |
| 293 | (if using-proxy (url-recreate-url url-http-target-url) real-fname) | 281 | (if using-proxy (url-recreate-url url-http-target-url) real-fname) |
| @@ -365,7 +353,10 @@ request.") | |||
| 365 | "\r\n" | 353 | "\r\n" |
| 366 | ;; Any data | 354 | ;; Any data |
| 367 | url-http-data)) | 355 | url-http-data)) |
| 368 | "")) | 356 | ;; Bug#23750 |
| 357 | (unless (= (string-bytes request) | ||
| 358 | (length request)) | ||
| 359 | (error "Multibyte text in HTTP request: %s" request)) | ||
| 369 | (url-http-debug "Request is: \n%s" request) | 360 | (url-http-debug "Request is: \n%s" request) |
| 370 | request)) | 361 | request)) |
| 371 | 362 | ||