escaping

How to select element that contains single quotes using XPath?

无人久伴 提交于 2019-12-24 09:47:49
问题 I would like to select this element using XPath : <a href="#" onClick="onViewDocument('2016', '1');">2016</a> So far I have this: //a[@onClick='onViewDocument('2016', '1');'] Do I need to escape the single quotes around the 2016 and 1 ? 回答1: Simplest usually is to use the alternative of ' or " , depending upon what was already used surrounding the string literal. If that's not feasible, an alternative is to use &apos; for ' ( single quote ): //a[@onClick='onViewDocument(&apos;2016&apos;,

How to select element that contains single quotes using XPath?

醉酒当歌 提交于 2019-12-24 09:43:30
问题 I would like to select this element using XPath : <a href="#" onClick="onViewDocument('2016', '1');">2016</a> So far I have this: //a[@onClick='onViewDocument('2016', '1');'] Do I need to escape the single quotes around the 2016 and 1 ? 回答1: Simplest usually is to use the alternative of ' or " , depending upon what was already used surrounding the string literal. If that's not feasible, an alternative is to use &apos; for ' ( single quote ): //a[@onClick='onViewDocument(&apos;2016&apos;,

Is casting to float destructive?

孤者浪人 提交于 2019-12-24 09:29:25
问题 In PHP, I know we shouldn't do math on floats without things like bcmath, but is the mere act of casting a string to float destructive? Will expressions like (float)'5.111' == '5.111' , always be true? Or will the cast itself change that to something like 5.1110000000000199837 as the number is converted? The main reason is, just as I use (int) to escape integer values going into a database, I would like to use (float) in the same way, without having to rely on quotes and my escape function.

system() copy fails, while cmd copy works

两盒软妹~` 提交于 2019-12-24 08:38:41
问题 In cmd.exe, I can execute the command "copy c:\hello.txt c:\hello2.txt" and it worked fine. But in my C program, I ran this piece of code and got the following error: #include <iostream> using namespace std; int main() { system("copy c:\hello.txt c:\hello2.txt"); system("pause"); return 0; } Output: The system cannot find the file specified. Anybody know what is going on here? 回答1: Inside C strings (and quite a few other languages that use the same escaping rules), \ should be \\ since it's

symfony i18n objects without output escaping

不打扰是莪最后的温柔 提交于 2019-12-24 07:03:04
问题 I am having a problem in Symfony 1.4 and Doctrine with getting the value of an i18n object without output escaping. Typically I just do this $object->getDescription(ESC_RAW); to get the value un-escaped. The problem comes in when I want to get a specific translation of the object. How do I specify the culture and the escaping strategy? I haven't found any documentation on this. Can I pass multiple parameters as an array or something similar to this: $object->getDescription(array('fr', ESC_RAW

How to have apostrophes in PHP string?

江枫思渺然 提交于 2019-12-24 06:01:02
问题 Part of my PHP code includes the construction of a URL string as follows: $msg = $_REQUEST["msg"]; $content = 'action=sendmsg'. '&user='.rawurlencode($username). '&password='.rawurlencode($password). '&to='.rawurlencode($destination). '&text='.rawurlencode($msg); When $msg happens to contain an apostrophe, it get sent as "\'" . What do I need to do to make sure the backslash is not inserted by PHP ? 回答1: You probably want to check out stripslashes: http://php.net/manual/en/function

Standard regex to prevent SPARQL injection?

房东的猫 提交于 2019-12-24 03:44:14
问题 I am developing a RESTful API in scala that sends SPARQL-queries to a triplestore. I read an article about the threat of SPARQL-injections when user defined params (URL params in a HTTP get request) are directly put in the SPARQL (e.g. in a fulltext search). I saw some Jena specific solutions (using its Java API) that are not useful for me. Is there some kind of standard regex search and replace pattern to escape malicious characters in a string that should be integrated in a SPARQL-query?

Why does _GET in PHP wrongly decodes slash?

ε祈祈猫儿з 提交于 2019-12-24 03:36:06
问题 Today I run into some oddity with PHP, which I fail find a proper explanation for in the documentation. Consider the following code: <?php echo $_GET['t']. PHP_EOL; ?> The code is simple - it takes a single t parameter on the url and outputs it back. So if you call it with test.php?t=%5Ca (%5c is a '\'), I expected to see: \a However, this is what I got: $ curl http://localhost/~boaz/test.php?t=%5Ca \\a Notice the double slash. Can anyone explains what's going on and give recipe for

get escaped unicode code from string

孤人 提交于 2019-12-24 03:08:26
问题 I seem to be having the opposite issue as everyone else in the development world. I need to generate escaped characters from strings. For instance, say I have the word MESSAGE: , I need to generate: \\u004D\\u0045\\u0053\\u0053\\u0041\\u0047\\u0045\\u003A\\u0053\\u0069\\u006D The closest thing I could get using Python was: u'MESSAGE:'.encode('utf16') # output = '\xff\xfeM\x00E\x00S\x00S\x00A\x00G\x00E\x00:\x00' My first thought was that I could replace \x with \u00 (or something to that

XSLT escaping >

三世轮回 提交于 2019-12-24 02:54:06
问题 i have a problem like a lot of people with escaping the > sign. the data xml file looks like <XML> <check><![CDATA[value > 60]]></check> </Xml> with xslt i would like to create a c# function. the checks are items that gone be used in a if statement. public void product(int value) { if( <xsl:value-of disable-output-escaping="yes" select="actie" />) this should be: if( value > 60 ) but returns if( value > 60 ) } <xsl:value-of cdata-section-elements="check"/> can't be used becouse i can't use