Opened 6 years ago

Closed 4 years ago

#17628 closed defect (fixed)

JsonRest : string concatenation of a null query

Reported by: gbranchaud Owned by: dylan
Priority: low Milestone: 1.11
Component: Data Version: 1.9.2
Keywords: Cc:
Blocked By: Blocking:

Description

I had issues with a JsonRest?-backed dgrid where upon sorting, the XHR request would come out as something like:

GET myserver.com/items/null?sort(+name)

Of course, I expected something like:

GET myserver.com/items/?sort(+name)

After investigation, I landed upon the query() method of the dojo/store/JsonRest.js file. The issue arises on line 176:

query += (query || hasQuestionMark ? "&" : "?") + (sortParam ? sortParam + '=' : "sort(");

In my case, query is null. So the code basically does null + "?" + "sort("; which results in the leading "null" string.

Since having a null query object at this point is a valid behavior, I think this is a bug in the store implementation.

The proposed fix is simply to add a line in between line 175 & 176 that would initialize query:

query = query || "";

Change History (3)

comment:1 Changed 4 years ago by dylan

Component: RPCData
Milestone: tbd1.11
Owner: set to dylan
Status: newassigned

Will review this soon hopefully.

comment:2 Changed 4 years ago by dylan

Priority: undecidedlow

comment:3 Changed 4 years ago by dylan

Resolution: fixed
Status: assignedclosed

Landed as https://github.com/dojo/dojo/commit/81f846d7a0de94e323a0f5ab4624b26091c4bc03 . Not backporting as it is a subtle change in behavior, even though it's fixing it to be more sane. Thanks gbranchaud!

Note: See TracTickets for help on using tickets.