escaping

How to escape <, >, and & characters to html entities in Oracle PL/SQL

不问归期 提交于 2019-11-29 11:48:39
问题 I need to send HTML emails directly from oracle PL/SQL package. This works almost fine. I have problem with the fact that some of the data fetched from a table contain things like <S> , <L> , and similar fragments, which sometimes ar treated as HTML tags, and even if not, they are always ignored and never displayed. So, I need to escape this column before inserting into email body. Is there a function to escape html special chars into entities automaticly? Or do I need to replace('<', '<',

How to escape output in PHP

試著忘記壹切 提交于 2019-11-29 11:46:31
I am a newbie, just to be clear. I hear a lot about escaping data to prevent XSS attacks. How do I actually do that? This is what I am doing currently - $s = mysqli_real_escape_string($connect,$_POST['name'])); Is this enough? Thanks SuperSpy If you output the data to html you should use htmlspecialchars() else, if you're storing the data in a database you should escape strings using mysqli_real_escape_string() and cast numbers (or use prepared statements for both) and protect identifiers/operators by whitelist-based filtering whem. Both these methods are all you need if you use them the

How to put unprocessed (escaped) words inside String.Format

北战南征 提交于 2019-11-29 11:32:01
问题 I am formatting a date: str = String.Format("{0:MMM d m:mm"+yearStr+"}", dt); I want to put the word "at" after the "d", but I don't want the string to format it. I just want the word "at". How can I achieve this? 回答1: You can surround literal strings with quotes, which for longer strings is probably easier and a bit more readable than escaping every character with a backslash: str = String.Format("{0:MMM d 'at' m:mm"+yearStr+"}", dt); See Custom Date and Time Format Strings in MSDN Library

Force repr() to use single quotes

梦想的初衷 提交于 2019-11-29 11:24:58
I have a question, is there a way to "force" repr() to create always single quotes around a string? This happens when I only use repr() print repr("test") 'test' print repr("test'") "test'" print repr("test\"") 'test"' print repr("test'\"") 'test\'"' so the last one actually does, what I want, but I don't want to add always \\" to get the single quotes. Edit: I am not going to mark an answer as accepted since, as pointed out by @martijn-pieters, I was using repr() for purposes it is not intended for. Well, if your object is always a string you could do this: def repr_single(s): return "'" +

Why isn't the “\\t” escaping this PHP date format?

送分小仙女□ 提交于 2019-11-29 11:24:34
Here's the date. Everything is being escaped but the t in "\a\t". Anybody know why? date("M m\, Y \a\t g\:ia", $s->post_date); "\t" is a escape sequence for the horizontal tab character. Use '\t' or "\\t" Single-quoted strings interpret \ literally, which I'd recommend for your use case. Otherwise you have to escape the \ character to have it interpreted literally. In PHP's case, the \ preceding an invalid escape sequence inside a double-quoted string also gets interpreted literally. I'd rather avoid this behavior, following the principle of least surprise. ps. (thanks to @IMSoP) There are two

Why I need to double-escape (use 4 \\) to find a backslash ( \\ ) in pure SQL?

[亡魂溺海] 提交于 2019-11-29 11:22:28
I do not understand this MySQL behaviour : if I want to display a\b, I can just select "a\\b" which work without problem : mysql> select "a\\b"; +-----+ | a\b | +-----+ | a\b | +-----+ 1 row in set (0.05 sec) But if I wnat to search a string containing a \ in a table using LIKE, I need to double-escape my "\". Why ? Here is an example. We prepare a small table. create table test ( test varchar(255) ); insert into test values ( "a\\b" ) , ( "a\\b\\c" ) , ( "abcd" ); mysql> select * from test; +-------+ | test | +-------+ | a\b | | a\b\c | | abcd | +-------+ 3 rows in set (0.05 sec) We try to

Do you have to escape a forward slash when using mod_rewrite?

核能气质少年 提交于 2019-11-29 11:09:57
问题 With regards to the forward slash "/" when giving a regex to RewriteRule or RewriteCond, or anything else related to .htaccess in particular, is there a need to escape the forward slash? Here is an example of what I am trying to achieve RewriteEngine on RewriteOptions inherit RewriteBase /uk-m-directory/ RewriteRule ^(region|region\/|regions\/)$ regions [R=301,L] RewriteRule ^(county|county\/|counties\/)$ counties [R=301,L] RewriteRule ^(city|city\/|cities\/)$ cities [R=301,L] The above works

How to escape asterisk in regexp?

强颜欢笑 提交于 2019-11-29 11:05:06
问题 I want to use the pattern *1* . I have tried \*1\* , but it doesn't work. Where is the problem? 回答1: You have to escape it with a backslash: /\*1\*/ Otherwise, an unescaped * in a RegExp will mean: Match 0 or more of the Preceding Character Group. Update: If you use the RegExp constructor, do it this way: new RegExp("\\*1\\*") You have to double-escape the backslashes because they need to be escaped in the string itself. 回答2: need to use a backslash \ as the escape character in regexes. 来源:

Escaping a double-quote in inline c# script within javascript

馋奶兔 提交于 2019-11-29 11:04:50
I need to escape a double quote in inline c# within javascript. Code is below: if ("<%= TempData["Message"]%>" == "") { // code }; Normally, I would just use single quotes like so: if ('<%= TempData["Message"]%>' == "") { // code }; However, TempData["Message"] has single quotes within it (when it contains a link generated by the Html.ActionLink() helper in ASP.NET MVC). So while I could change all the ActionLink helpers inside TempData["Message"] to tags, it's an interesting problem and would been keen to hear if anyone has an answer. Call HttpUtility.JavaScriptStringEncode . This method is

Escaping output safely for both html and input fields

眉间皱痕 提交于 2019-11-29 11:03:30
In my web app, users can input text data. This data can be shown to other users, and the original author can also go back and edit their data. I'm looking for the correct way to safely escape this data. I'm only sql sanitizing on the way in, so everything is stored as it reads. Let's say I have "déjà vu" in the database. Or, to be more extreme, a <script> tag. It is possible that this may be valid, and not even maliciously intended, input. I'm using htmlentities() on the way out to make sure everything is escaped. The problem is that html and input fields treat things differently. I want to