Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Take A QuizChallenge yourself and boost your learning! Start the quiz now to earn credits.
Take A QuizUnlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Take A QuizGeneral Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
The problem is with $ sign. It's a special character and it should be escaped, because normally it means end of input. You have to update regescape
function, because it escapes only single quote and square brackets - so you have at least add dollar sign there too.
Also seems like your regescape
function does not work as expected in some cases. Try for example to pass this value: test[]'
. I think you expect to get test\[\]\'
, but actually you will get test\[]'
So in order to fix it and add dolar sign - it should be something like this:
var regescape = function(text) {
return text.replace(/'|\$|\[|\]/g, "\\$&");
};
Pipe (|) means or
, so it simply escapes any of the symbols from the set. You can easily add more characters there in future.
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.
manpreet
Best Answer
2 years ago
In my Node js, I have escaped single quote with the below function
This is working fine for me. But suddenly I discovered I have a string M'$ in my database. Which is not returning with my below query.
Also Please suggest the best practice for handling Node JS parameter pass to MongoDB. I am calling NodeJS from PHP code. And I am sending parameters with
rawurlencode()
from PHP code. In node js I'm usingdecodeURI()
to the received parameters.Edit:
My PHP code for calling Node JS:
Node JS code to receive data: