[Qt-interest] how to pass strings as args to evaluateJavascript() call?

Jason H scorp1us at yahoo.com
Mon Mar 14 15:54:49 CET 2011


I think the right approach here is to get a pointer to the recalc function and 
pass the parameters as paramters and NOT as any kind of text parameter. There is 
a C++ API for this, but I haven't used it in a while.

The next best thing is to place str1 and str2 into your JS engine, and use the 
call like you have it. Do NOT do eval("var str1='aaa'") as it is no better than 
the worst thing you could do.

The worst would be to construct the whole thing as a string as you would have an 
eval() vulnerability similar to a SQL injection attack.





________________________________
From: Karthick <sppkarthick at gmail.com>
To: qt-interest at trolltech.com; qt-interest at qt.nokia.com; 
qtopia-interest at trolltech.com
Sent: Mon, March 14, 2011 2:43:24 AM
Subject: [Qt-interest] how to pass strings as args to evaluateJavascript() call?

Hi All,
How to pass strings as args to evaluatejavascript() call?
For example:
I have a Javascript function in HTML which is given below.
calcRoute(origin, destination);

I have tried the following way.
In Qt:
I am calling JS function like evaluateJavascript("calRoute('germany', 
'italy')");
In this case, no issues. Here i passed the hard coded value.
Instead of that, i will pass two strings as given below. 
char *str1, *str2;
//memory allocation for str1 and str2
strcpy(str1, "germany");
strcpy(str2, "italy");
evaluateJavascript("calcRoute(str1, str2)");
In this case, no compilation error. but i am not getting proper output.
whether is this correct way to pass strings like the one above or will do it in 
sum other way to pass? 

If anyone knows, please help me to solve this issue.


-- 
Regards,
Karthick


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110314/b2612c1a/attachment-0001.html 


More information about the Qt-interest-old mailing list