Skip to content

FOGL-7274: Fixed issue in asset tracker with single or double quotes in asset name#970

Closed
gnandan wants to merge 23 commits intodevelopfrom
FOGL-7274_1
Closed

FOGL-7274: Fixed issue in asset tracker with single or double quotes in asset name#970
gnandan wants to merge 23 commits intodevelopfrom
FOGL-7274_1

Conversation

@gnandan
Copy link
Member

@gnandan gnandan commented Feb 15, 2023

No description provided.

Innovative-ashwin and others added 2 commits December 22, 2022 19:03
…ecial characters

Signed-off-by: Innovative-ashwin <sinha.ashwini111@gmail.com>
…s in asset name

Signed-off-by: nandan <nandan.ghildiyal@gmail.com>
@gnandan gnandan changed the title FOGL-7274_ : Fixed issue in asset tracker with single or double quotes in asset name FOGL-7274_ 1: Fixed issue in asset tracker with single or double quotes in asset name Feb 15, 2023
@gnandan gnandan changed the title FOGL-7274_ 1: Fixed issue in asset tracker with single or double quotes in asset name FOGL-7274_1: Fixed issue in asset tracker with single or double quotes in asset name Feb 15, 2023
@gnandan gnandan changed the title FOGL-7274_1: Fixed issue in asset tracker with single or double quotes in asset name FOGL-7274: Fixed issue in asset tracker with single or double quotes in asset name Feb 15, 2023
@gnandan gnandan requested review from AmandeepArora, Innovative-ashwin and MarkRiddoch and removed request for AmandeepArora February 15, 2023 13:14
gnandan and others added 2 commits February 16, 2023 10:57
Signed-off-by: nandan <nandan.ghildiyal@gmail.com>
// Handles - asset_code
sql.append(",\'");
sql.append((*itr)["asset_code"].GetString());
std::string escacpedAsset((*itr)["asset_code"].GetString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix the spelling "escacped".

}
else
{
std::string escacpedAsset(asset_code);
Copy link
Contributor

Choose a reason for hiding this comment

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

Spelling again.

+ to_string(ref.tableId) + ","
+ to_string(ref.dbId) + ","
+ "\"" + asset_code + "\")";
+ "\"" + escacpedAsset.c_str() + "\")";
Copy link
Contributor

Choose a reason for hiding this comment

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

escacped should be escaped

@gnandan
Copy link
Member Author

gnandan commented Feb 16, 2023

Asset name is inserted with single quote escaped twice after updating the branch. Identified the issue , it needs code fix in connection.cpp file of sqlite plugin to stop escaping twice.

gnandan and others added 4 commits March 30, 2023 19:31
Signed-off-by: nandan <nandan.ghildiyal@gmail.com>
Signed-off-by: nandan <nandan.ghildiyal@gmail.com>
Signed-off-by: nandan <nandan.ghildiyal@gmail.com>
Copy link
Contributor

@AmandeepArora AmandeepArora left a comment

Choose a reason for hiding this comment

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

Since some basic classes have been changed, it might be good to add some test cases, may be in a separate JIRA.

sql.append(",\'");
sql.append((*itr)["asset_code"].GetString());
std::string escapedAsset((*itr)["asset_code"].GetString());
escapedAsset = std::regex_replace(escapedAsset, std::regex("\'"), "\'\'");
Copy link
Contributor

Choose a reason for hiding this comment

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

Regex is a really slow way of doing this. We used to make more use of regex but removed it because of the big impact it had on performance. You are not using any regular expressions here, so there are much simpler and more performant ways to do this.

sql_cmd =

std::string escapedAsset(asset_code);
escapedAsset = std::regex_replace(escapedAsset, std::regex("\""), "\"\"");
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment above about not using regex

dbName = generateDbName(item.second.second);
dbReadingsName = generateReadingsName(item.second.second, item.second.first);

assetCode = std::regex_replace(assetCode, std::regex("\'"), "\'\'");
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment above about not using regex

gnandan and others added 2 commits June 1, 2023 12:06
@gnandan gnandan requested review from AmandeepArora, Innovative-ashwin and MarkRiddoch and removed request for Innovative-ashwin June 1, 2023 13:30
@gnandan gnandan removed the request for review from Innovative-ashwin June 26, 2023 05:28
#include <common.h>
#include "readings_catalogue.h"
#include <purge_configuration.h>
#include <regex>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably not required?

@MarkRiddoch
Copy link
Contributor

Asset tracker has changed so closing this PR and will work changes into the new mechanism

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants