Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline POST body collapsed #297

merged 1 commit into from Aug 24, 2018


Copy link

@robertdj robertdj commented Aug 20, 2018

Fixes #270

Copy link

CLAassistant commented Aug 20, 2018

CLA assistant check
All committers have signed the CLA.

Copy link

codecov-io commented Aug 20, 2018

Codecov Report

Merging #297 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #297   +/-   ##
  Coverage   90.01%   90.01%           
  Files          25       25           
  Lines        1142     1142           
  Hits         1028     1028           
  Misses        114      114
Impacted Files Coverage Δ
R/post-body.R 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 20cd7a3...0b8148a. Read the comment docs.

@schloerke schloerke merged commit d8edd45 into rstudio:master Aug 24, 2018
4 checks passed
Copy link

boglesby03 commented Oct 10, 2018

Not everything posted is single line. We're using plumber to post csv's so we need the returns in the body of the message.

schloerke added a commit to schloerke/plumber that referenced this pull request Oct 29, 2018
* master:
  Protect from unsafe JSON parsing behavior. (rstudio#325)
  use `inherits(obj, "xxx")` and `expect_s3_class(obj, "xxx")` rather than "xxx" %in% class(obj) (rstudio#313)
  Multiline POST body collapsed (rstudio#297)
  Install plumber from CRAN in top level Docker file (rstudio#292)
@@ -1,7 +1,7 @@
postBodyFilter <- function(req){
handled <- req$.internal$postBodyHandled
if (is.null(handled) || handled != TRUE){
body <- req$rook.input$read_lines()
body <- paste0(req$rook.input$read_lines(), collapse = "\n")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if post body has valid returns in it? Such as a csv, or a text field that has intentional returns in it? Blanket removing returns isn't the correct solution.

Copy link

@schloerke schloerke Nov 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read_lines() should only be returning a character vector for each line of text. If the text has a newline value in it, it should be escaped and be interpreted as regular text.

By collapsing the text with \n, the original new line locations are preserved. This makes the postBody a single character value (correct), not a vector of character values (incorrect).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

5 participants