Openbravo Issue Tracking System - Retail Modules
View Issue Details
0051515Retail ModulesWeb POSpublic2023-01-31 12:462023-02-27 11:56
gorkaion 
ranjith_qualiantech_com 
highmajoralways
closedfixed 
5
 
RR23Q2 
No
0051515: Wrong json encode on DS.Request when the json has a string value with the "/" character
In the customer instance the issue is reproduced when scanning a document number that has the "/" character. This scan is calling a backend custom service using OB.DS.Request:

new OB.DS.Request(customService).exec({param: "param/with/character}, callback, error)

These executes a GET call to backend the json with the parameters is encoded using encodeURI in ob-datasource.js [1] This is not scaping the / character so it is sent as it is in the request.

MobileService in backend manage this request. To get the parameters the service is executing a split of the url by "/" [2]. Since the original / is not encoded the split is wrong causing a failure initializing the JSONObject with the parameters. As a result the custom service is called with an empty JSONObject



[1] https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/blob/master/web/org.openbravo.mobile.core/source/data/ob-datasource.js#L281 [^]
[2] https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/blob/master/src/org/openbravo/mobile/core/process/MobileService.java#L168 [^]
Unknown how to execute in a clean POS. Any request to backend using OB.DS.Request().exec() with a parameter value containing the "/" should make it fail.

Livebuilds
Login POS
Open Console and run below code
var params = {};
params.sample = { a: 'X/X' };
params.bpartnerId = 'ABD91C9D3BC94175B876FBBE9CACA008';
params.bpLocationId = '2AA7EADDF7EC405899262DDA3E572436';
new OB.DS.Request('org.openbravo.retail.posterminal.master.LoadedCustomer').exec(params, async function(data) { console.log(data); });
Error will occur in request
Isntead of using encodeURI use encodeURIComponents to encode the json string.

https://thisthat.dev/encode-uri-vs-encode-uri-component/ [^]

And
ENCODED_SLASH should be updated in Apache and Tomcat
https://stackoverflow.com/questions/4390436/need-to-allow-encoded-slashes-on-apache [^]
https://stackoverflow.com/questions/39931538/how-to-set-allow-encoded-slash-in-tomcat-8 [^]
No tags attached.
Issue History
2023-01-31 12:46gorkaionNew Issue
2023-01-31 12:46gorkaionAssigned To => Retail
2023-01-31 12:46gorkaionTriggers an Emergency Pack => No
2023-02-02 12:36ranjith_qualiantech_comAssigned ToRetail => ranjith_qualiantech_com
2023-02-03 10:23ranjith_qualiantech_comStatusnew => scheduled
2023-02-06 07:49ranjith_qualiantech_comSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=25498#r25498
2023-02-06 07:49ranjith_qualiantech_comProposed Solution updated
2023-02-07 05:46hgbotNote Added: 0146280
2023-02-27 11:56hgbotResolutionopen => fixed
2023-02-27 11:56hgbotStatusscheduled => closed
2023-02-27 11:56hgbotNote Added: 0147030
2023-02-27 11:56hgbotFixed in Version => RR23Q2
2023-02-27 11:56hgbotNote Added: 0147031

Notes
(0146280)
hgbot   
2023-02-07 05:46   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/merge_requests/469 [^]
(0147030)
hgbot   
2023-02-27 11:56   
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/merge_requests/469 [^]
(0147031)
hgbot   
2023-02-27 11:56   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core [^]
Changeset: 2c99a41586798d1fcb8d27cf82f56589ac05ae82
Author: Ranjith S R <ranjith@qualiantech.com>
Date: 27-02-2023 10:55:39
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.mobile.core/-/commit/2c99a41586798d1fcb8d27cf82f56589ac05ae82 [^]

Fixed ISSUE-51515: Used encodeURIComponent to encode json string for GET request

---
M web/org.openbravo.mobile.core/source/data/ob-datasource.js
---