GitToTheHub commented on code in PR #313:
URL: https://github.com/apache/cordova-paramedic/pull/313#discussion_r3664354159
##########
lib/ParamediciOSPermissions.js:
##########
@@ -55,24 +55,28 @@ class ParamediciOSPermissions {
for (const service of serviceList) {
const app = this.appName;
+ const escapedService = service.replace(/'/g, "''");
+ const escapedApp = app.replace(/'/g, "''");
// If the service has an entry already, the insert command will
fail.
// in this case we'll process with updating existing entry
+ const insertSQL = '"INSERT INTO access (service, client,
client_type, allowed, prompt_count, csreq) VALUES(\'' + escapedService + '\',
\'' + escapedApp + '\', 0, 1, 1, NULL)"';
const insetProc = await spawnAsync(
'sqlite3',
[
destinationTCCFile,
- `"INSERT INTO access (service, client, client_type,
allowed, prompt_count, csreq) VALUES('${service}', '${app}', 0, 1, 1, NULL)"`
+ insertSQL
Review Comment:
You can leave the template literals here also
##########
lib/ParamediciOSPermissions.js:
##########
@@ -55,24 +55,28 @@ class ParamediciOSPermissions {
for (const service of serviceList) {
const app = this.appName;
+ const escapedService = service.replace(/'/g, "''");
+ const escapedApp = app.replace(/'/g, "''");
// If the service has an entry already, the insert command will
fail.
// in this case we'll process with updating existing entry
+ const insertSQL = '"INSERT INTO access (service, client,
client_type, allowed, prompt_count, csreq) VALUES(\'' + escapedService + '\',
\'' + escapedApp + '\', 0, 1, 1, NULL)"';
const insetProc = await spawnAsync(
'sqlite3',
[
destinationTCCFile,
- `"INSERT INTO access (service, client, client_type,
allowed, prompt_count, csreq) VALUES('${service}', '${app}', 0, 1, 1, NULL)"`
+ insertSQL
]
);
if (insetProc.code) {
logger.warn(`[paramedic] Failed to insert permissions for
${app} into ${destinationTCCFile}. Will try to update existing permissions.`);
+ const updateSQL = '"UPDATE access SET client_type=0,
allowed=1, prompt_count=1, csreq=NULL WHERE service=\'' + escapedService + '\'
AND client=\'' + escapedApp + '\'"';
const updateProc = await spawnAsync(
'sqlite3',
[
destinationTCCFile,
- `"UPDATE access SET client_type=0, allowed=1,
prompt_count=1, csreq=NULL WHERE service='${service}' AND client='${app}'"`
+ updateSQL
Review Comment:
You can leave the template literals
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]