escaping

How do you display a field with an embedded quote mark in JSON-LD?

强颜欢笑 提交于 2019-12-11 07:35:02
问题 JSON-LD fields are supposed to be double quoted "name": "value", but what if the value has an embedded double quote, like "name" : "Magnetic Strip (36" Length)" Is it sufficient to escape the double quote "name" : "Magnetic Strip (36\" Length)" or is there a better way? 回答1: Yes, backslashes have to be used for escaping double quotes in string values: A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes (if necessary). (Number, boolean

MySQL_real_escape_string not adding slashes?

狂风中的少年 提交于 2019-12-11 07:25:53
问题 So I do this: <?php session_start(); include("../loginconnect.php"); mysql_real_escape_string($_POST[int]); $int = nl2br($_POST[int]); $query = "UPDATE `DB`.`TABLE` SET `interests`='$int' WHERE `user`='$_SESSION[user]'"; mysql_query($query) or die(mysql_error()); mysql_close($con); ?> And let's say that $_POST[int] is "Foo' bar." The single-quote remains unescaped AND I get a MySQL error when running the script, due to the quote. What's wrong? 回答1: m_r_e_s() RETURNS the escaped value, it

LDAP search in java: DN contains ,

ぐ巨炮叔叔 提交于 2019-12-11 07:04:36
问题 I'm currently running into issues when searching for entries where the DN contains a comma: StringTokenizer st = new StringTokenizer(dn, "="); Attributes searchAttributes = new BasicAttributes(st.nextToken(), st.nextToken()); Enumeration results = ctx.search(baseDn, searchAttributes); if (results.hasMoreElements()) { // ... } I tested both dn=first,second as well as dn=first\,second , and although the search runs correctly, I never get any results back . The same baseDn and dn works correctly

Escape quotes in a string with backslash

眉间皱痕 提交于 2019-12-11 06:22:35
问题 I have a string: " \" " . I would like to escape all unescaped double-quotes, i.e. add a backslash before " if it's note there. input = '" \\" "' input.replace(???) == '\\" \\" \\"' I've tried input.replace(/(?!\\)"/g, '\\"') It escapes second backslash twice ( '\" \\" \"' ) for the reason I don't understand. I've figured out (' ' + input).replace(/([^\\])"/g, '$1\\"').slice(1) But it looks ugly. It has to be a better way. Update: One more test case: >> input = '" \\" \\\\" \\\\\\"' -> '" \"

mysql_real_escape_string() in .NET Framework

随声附和 提交于 2019-12-11 06:15:56
问题 i want to find a function in .NET framework to calls SQL-Server's library for escaping really a value for sending to sql server, as mysql-real-escape-string() calls MySQL's library to do in PHP. please propose a method that i can call it and it return escaped string via one round-trip to database, no need fo executing It's query Is there it? 回答1: Why do you want to do that? The correct way to send user input to the database is not to escape it, but to use query parameters. using(var command =

FAILED: ParseException line 1:21 cannot recognize input near '<EOF>' '<EOF>' '<EOF>' in table name

左心房为你撑大大i 提交于 2019-12-11 06:15:31
问题 Command: hive -e "use xxx;DROP TABLE IF EXISTS `xxx.flashsaleeventproducts_hist`;CREATE EXTERNAL TABLE `xxx.flashsaleeventproducts_hist`(`event_id` string,`group_code` string,`id` string,`is_deleted` int,`price` int,`price_guide` int,`product_code` int,`product_id` string,`quantity_each_person_limit` int,`quantity_limit_plan` int,`sort_num` int,`update_time` bigint,`meta_offset` bigint,`meta_status` int,`meta_start_time` bigint)PARTITIONED BY(`cur_date` string,`cur_hour` string) ROW FORMAT

How to escape backslash and double quotes with awk

倖福魔咒の 提交于 2019-12-11 04:49:38
问题 I have some awk that rearrange a line. I would like to escape one of the variables (e.g. $_), in such way that " and \ are escaped with a backslash. Example: echo "Ehm, \"hi\", he \\ said" | awk '{$1="" ; print "\"" $_ "\"" }' " "hi", he \ said" (do not change the echo, normally I read from a file that has Ehm, "hi", he \ said in it). I would like to have " \"hi\", he \\ said" instead. How can I do this? Is there a function in awk that can do this? 回答1: Is there a reason you resort to awk?

How to remove magic quotes if php.ini/.htaccess are not editable?

时光怂恿深爱的人放手 提交于 2019-12-11 04:29:52
问题 For some reason, all my quotes are being escaped and displayed as \". Previously, it was okay. Then I looked at phpinfo() and saw that my magic_quotes_gpc is turned on. However, I cannot find the directory /usr/local/lib/ where php.ini file is and I cannot edit my .htaccess file (gets 500 Internal Server Error). I tried putting this instead on top of my scripts file (which is included in all pages): if (get_magic_quotes_gpc()) { $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); while

Escaping a colon in powershell

☆樱花仙子☆ 提交于 2019-12-11 04:20:45
问题 I have the following piece of code in powershell trying to read back a piece of xml. $path = "C:\path\8429006775491.xml" $xml = [xml](Get-Content $path) $xml.ern:NewReleaseMessage The problem is the colon(:), i've tried to escape it with ' but it doesn't seem to work. Also tried to put it in {} If i edit the colon in the xml file itself and change the code accordingly it reads back fine but unfortunately that is not an option. Any help really appreciated. 回答1: In order for .NET to understand

building django template files with xslt

时间秒杀一切 提交于 2019-12-11 04:12:01
问题 I have about 4,000 html documents that i am trying to convert into django templates using xslt. The problem that I am having is that xslt is escaping the '{' curly braces for template variables, when I try to include a template variable inside of an attribute tag; my xslt file looks like this: <xsl:template match="p"> <p> <xsl:attribute name="nid"><xsl:value-of select="$node_id"/></xsl:attribute> <xsl:apply-templates select="*|node()"/> </p> <span> {% get_comment_count for thing '<xsl:value