escaping

Why do Java octal escapes only go up to 255?

喜夏-厌秋 提交于 2019-11-30 09:14:56
问题 The Java language specification states that the escapes inside strings are the "normal" C ones like \n and \t , but they also specify octal escapes from \0 to \377 . Specifically, the JLS states: OctalEscape: \ OctalDigit \ OctalDigit OctalDigit \ ZeroToThree OctalDigit OctalDigit OctalDigit: one of 0 1 2 3 4 5 6 7 ZeroToThree: one of 0 1 2 3 meaning that something like \4715 is illegal, despite it being within the range of a Java character (since Java characters are not bytes). Why does Java

Escaping escape Characters

时光怂恿深爱的人放手 提交于 2019-11-30 09:11:35
I'm trying to mimic the json_encode bitmask flags implemented in PHP 5.3.0, here is the string I have: $s = addslashes('O\'Rei"lly'); // O\'Rei\"lly Doing json_encode($s, JSON_HEX_APOS | JSON_HEX_QUOT) outputs the following: "O\\\u0027Rei\\\u0022lly" And I'm currently doing this in PHP versions older than 5.3.0: str_replace(array('\\"', "\\'"), array('\\u0022', '\\\u0027'), json_encode($s)) or str_replace(array('\\"', '\\\''), array('\\u0022', '\\\u0027'), json_encode($s)) Which correctly outputs the same result: "O\\\u0027Rei\\\u0022lly" I'm having trouble understanding why do I need to

Executing shell command in background from ruby with proper argument escaping

≡放荡痞女 提交于 2019-11-30 09:05:15
I have to run a command in the background but I want to have proper escaping for its parameter. system("rake send_mails subject='#{params[:subject]}' 2> /dev/null 1> /dev/null &"); If I write system("rake", "send_mails", params[:subject]) then I don't have "place" for redirections and the & sign. If I don't I do not have escaping for the subject parameter. How can I resolve this? In Ruby 1.9, try Process.spawn : # Spawn a new process and run the rake command pid = Process.spawn({"subject" => params[:subject]}, "rake", "send_mails", :out => 'dev/null', :err => 'dev/null') # Detach the spawned

Java, escaping (using) quotes in a regex

柔情痞子 提交于 2019-11-30 08:52:47
问题 I'm trying to use the following regex in Java, that's supposed to match any lang="2-char-lang-name" : String lang = "lang=\"" + L.detectLang(inputText) +"\""; shovel.replaceFirst("lang=\"[..]\"", lang); I know that a single slash would be interpreted by regex as a slash and not an escape character (so my code doesn't work), but if I escape the slash, the " won't be escaped any more and I'd get a syntax error. In other words, how can I include a " in the regex? "lang=\\"[..]\\"" won't work. I

Rails 4, link in flash message is not parsed as HTML

一笑奈何 提交于 2019-11-30 08:42:42
问题 In controller I have the following flash message: flash[:notice] = %Q[Please #{view_context.link_to('create a new account', new_account_path)}, after that you will be able to create orders.].html_safe Here is flash area in layout: <div id="main_flash_area"> <% flash.each do |name, msg| %> <div class="alert text-center alert-info"> <a class="close" data-dismiss="alert">× Закрыть</a> <%= msg %> </div> <% end %> </div> It kinda renders into a link, but browser doesn't parse it as a link though.

MySQL unicode literals

对着背影说爱祢 提交于 2019-11-30 08:32:05
I want to insert a record into MySQL that has a non-ASCII Unicode character, but I'm on a terminal that doesn't let me easily type non-ASCII characters. How do I escape a Unicode literal in MySQL's SQL syntax? dkamins See: http://bugs.mysql.com/bug.php?id=10199 (Bug #10199: "Allow Unicode escape sequence for string literals.") This request has been "Open" since 2005. More details in Worklog Task #3529: Unicode Escape Sequences . From https://web.archive.org/web/20091117221116/http://eng.kaching.com/2009/10/mysql-unicode-escape-sequences.html though, you can see the following example, which

Color escape codes in pretty printed columns

那年仲夏 提交于 2019-11-30 08:29:52
问题 I have a tab-delimited text file which I send to column to "pretty print" a table. Original file: 1<TAB>blablablabla<TAB>aaaa bbb ccc 2<TAB>blabla<TAB>xxxxxx 34<TAB>okokokok<TAB>zzz yyy Using column -s$'\t' -t <original file> , I get 1 blablablabla aaaa bbb xxx 2 blabla xxxxxx 34 okokokok zzz yyy as desired. Now I want to add colors to the columns. I tried to add the escape codes around each tab-delimited field in the original file. column successfully prints in color, but the columns are no

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

我只是一个虾纸丫 提交于 2019-11-30 08:12:18
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('<', '<', string) manually all the special characters? You can use the htf.escape_sc function: SQL> select htf

JSTL escaping special characters [duplicate]

江枫思渺然 提交于 2019-11-30 08:10:56
This question already has an answer here: XSS prevention in JSP/Servlet web application 8 answers I have this weird issue with special characters. In JSP, I am using field name as id and the name can be anything like id="&lt;1 and &>2" (OR) id="aaa & bbb" I don't have any other option to use ID's other than names, that what the only thing I get from backend. So, Is there any logic to remove all the special characters using JSTL. With the present scenario, In JS I will do some operations with the ID. this is causing many issues for each kind of browser. Please suggest, Thanks in advance... JB

Any way to escape a Go string in a regular expression?

半世苍凉 提交于 2019-11-30 08:09:26
I'm wanting to match ^(@|\s)*{{string}}:? whereas {{string}} is dynamically defined. It may have periods and dashes and any number of things in it and I really need for it to be escaped. PHP provides a preg_quote method that escapes all special characters safely. I was wondering if Go provides any sort of analog. donatJ regexp.QuoteMeta does the deed. 来源: https://stackoverflow.com/questions/27415532/any-way-to-escape-a-go-string-in-a-regular-expression