5.3.9 regression, unknown content type causes null pointer exception

Description

Due to the fix here:
https://github.com/Ortus-Solutions/Lucee/commit/a3d8c6109472da47a4e1444cd4eacd676f5e3194

The code was refactored in such a way that it throws an NPE when a content type is set that Lucee does not recognize.

This code will reproduce the error on Lucee 5.3.9.108

The error is

The bad line of code is

which was recently changed. The problem is the isTextMimeType() method was recently changed to return a `Boolean` class instance instead of a `boolean` primitive (lowercase). Primitives can't be null, but class instances can. So the new code path that was added added to return a null gives us an NPE when we check the value of it. If Lucee is going to return a Boolean type from that method and sometimes that return will be null, every place that checks the return value of that method needs to check for null AS WELL AS a boolean value.

Environment

None

Activity

Pothys - MitrahSoft 
21 March 2022 at 10:38

I've checked this ticket with the lucee latest build 5.3.9.113-SNAPSHOT and now the issue was solved.

Michael Offner 
21 March 2022 at 09:17

please give this build a try

Michael Offner 
18 March 2022 at 14:40

problem was a mistake in translation of the code from boolean to Boolean.

Code was before

if(!HTTPUtil.isTextMimeType(type)) {

back then isTextMimeType did return a boolean, what never can be null. Then we changed that the return type to Boolean, what of course can be null.

i changed the code to this

if(!HTTPUtil.isTextMimeType(type) == Boolean.TRUE) {

i missed the “!“ what did cause the issue, then of course we cannot inverse null. Correct would be

if(!(HTTPUtil.isTextMimeType(type) == Boolean.TRUE)) {

Michael Offner 
18 March 2022 at 14:33

Zac Spitzer 
16 March 2022 at 17:59

cfdocument tests added, means one is disabled

Fixed

Details

Assignee

Reporter

Priority

Fix versions

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Affects versions

Created 15 March 2022 at 21:56
Updated 21 March 2022 at 10:38
Resolved 21 March 2022 at 10:38