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

Add support for CSP Reporting & ndJSON #397

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/api.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,17 @@

<cfset requestObj.body = getRequestBody() />
<cfset requestObj.contentType = cgi.content_type />

<cfif not len(requestObj.contentType) and isSimpleValue(requestObj.body) and isJSON(requestObj.body)>
<cfset requestObj.contentType = "application/json">
<cfelseif isSimpleValue(requestObj.body) and listlen(requestObj.Body,chr(10)) GT 1 and not isJSON(requestObj.body) and isJSON("[" & javacast("string", requestObj.body).replace("\n", ",") & "]")>
Copy link
Owner

Choose a reason for hiding this comment

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

Just had a thought: what if there's only 1 row in the ndJson body? your listLen() param will evaluate to false. 🤔

<cfset requestObj.contentType = "application/json">
<cfset requestObj.body = "[" & javacast("string", requestObj.body).replace("\n", ",") & "]">
</cfif>

<cfif requestObj.contentType is "application/csp-report">
<cfset requestObj.contentType = "application/json">
</cfif>
<cfif len(requestObj.body) AND requestObj.body neq "null">
<cfif findNoCase("multipart/form-data", requestObj.contentType)>
<!--- do nothing, to support the way railo handles multipart requests (just avoids the error condition below) --->
Expand Down