escaping

Escape comment character (#) in git commit message [duplicate]

末鹿安然 提交于 2019-11-30 08:03:01
This question already has an answer here: Start a git commit message with a hashmark (#) 8 answers I have set mcedit as my editor for git commit messages. By default it ignores any lines starting with the # character. However odd this may seem, I need to be able to have the my commit message looking like this: #FOO-123: Implement bar foo Committing work in progress The #FOO-123: ... is actually the key + title of an issue in our tracker. The tracker can automatically pick up these commit messages and add them to the issue. Unfortunately, the first line gets treated like a comment and gets

Escape Quotes In HTML5 Data Attribute Using Javascript

送分小仙女□ 提交于 2019-11-30 07:56:57
I'm using jQuery's .data() to work with custom HTML5 data attributes where the value of the attribute needs to be able to contain both single quotes and double quotes: <p class="example" data-example="She said "WTF" on last night's show."> I know using character codes like " in the data attribute value could make the above work, but I can't always control how the values are inputted. Plus, I need to be able to use HTML tags in the markup, like this: <p class="example" data-example=" She said "<abbr title="What The F***">WTF</abbr>" on last night's show. "> If some form of .replace() is the

How can I scp a file with a colon in the file name?

醉酒当歌 提交于 2019-11-30 07:54:28
I'm trying to copy a file using scp in bash with a colon ( : ) character in the source filename. The obfuscated version of my command I'm using is: scp file\:\ name.mp4 user@host:"/path/to/dest" I get this error: ssh: Could not resolve hostname Portal 2: Name or service not known I know I could just rename the file and remove the : , but I'd like to know if it's possible to escape the colon. Not quite a bash escaping problem, it's scp treating x: as a [user@]host prefix, try: scp ./file:\ name.mp4 user@host:"/path/to/dest" Using relative (e.g. ./ ) or fully qualified paths ( /path/to/source )

Cannot get xslt to output an (&) even after escaping the character

会有一股神秘感。 提交于 2019-11-30 07:52:11
问题 I am trying to create a query string of variable assignments separated by the & symbol (ex: "var1=x&var2=y&..." ). I plan to pass this string into an embedded flash file. I am having trouble getting an & symbol to show up in XSLT. If I just type & with no tags around it, there is a problem rendering the XSLT document. If I type & with no tags around it, then the output of the document is & with no change. If I type <xsl:value-of select="&" /> or <xsl:value-of select="&" /> I also get an error

Prevent django admin from escaping html

强颜欢笑 提交于 2019-11-30 07:51:44
I'm trying to display image thumbnails in django admin's list_display and I am doing it like this: from django.utils.safestring import mark_safe class PhotoAdmin(admin.ModelAdmin): fields = ('title', 'image',) list_display = ('title', '_get_thumbnail',) def _get_thumbnail(self, obj): return mark_safe(u'<img src="%s" />' % obj.admin_thumbnail.url) Admin keeps displaying the thumbnail as escaped html, although I marked the string as safe. What am I doing wrong? As of Django 1.9, you can use format_html() , format_html_join() , or allow_tags in your method. See the list_display docs for more info

ffmpeg single quote in drawtext

£可爱£侵袭症+ 提交于 2019-11-30 07:12:09
问题 I haven't been able to get ffmpeg's drawtext video filter to draw apostrophes/single quotes when they are in drawtext's "text=" parameter, even when I escape them. Double quotes work fine, and apostrophes in text loaded from a file (e.g. textfile="example.txt") work fine. Is this a bug? e.g. ffmpeg -i test.mpg -vf drawtext="apostrophes don't print" ... ffmpeg -i test.mpg -vf drawtext="even when they\'re escaped" ... 回答1: Special character escapes are like violence: if they're not solving your

PHP ldap_add function to escape ldap special characters in DN syntax

社会主义新天地 提交于 2019-11-30 06:54:54
I'm trying to add some users to my Ldap DB but I get some errors (invalid dn syntax) when I use some special characters like ",.". I need a function that escape all characters. I try preg_quote but I get some errors in some cases. Thanks in advance Code: $user = 'Test , Name S.L'; if(!(ldap_add($ds, "cn=" . $user . ",".LDAP_DN_BASE, $info))) { include 'error_new_account.php'; } DaveRandom EDIT Jan 2013: added support for escaping leading/trailing spaces in DN strings, per RFC 4514 . Thanks to Eugenio for pointing out this issue. EDIT 2014: I added this function to PHP 5.6 . The code below is

How can I replace a plus sign in JavaScript?

余生长醉 提交于 2019-11-30 06:54:25
问题 I need to make a replace of a plus sign in a javascript string. there might be multiple occurrence of the plus sign so I did this up until now: myString= myString.replace(/+/g, "");# This is however breaking up my javascript and causing glitches. How do you escape a '+' sign in a regular expression? 回答1: myString = myString.replace(/\+/g, ""); 回答2: You need to escape the + as its a meta char as follows: myString= myString.replace(/\+/g, ""); Once escaped, + will be treated literally and not

Using encodeURI() vs. escape() for utf-8 strings in JavaScript

柔情痞子 提交于 2019-11-30 06:36:28
I am handling utf-8 strings in JavaScript and need to escape them. Both escape() / unescape() and encodeURI() / decodeURI() work in my browser. escape() > var hello = "안녕하세요" > var hello_escaped = escape(hello) > hello_escaped "%uC548%uB155%uD558%uC138%uC694" > var hello_unescaped = unescape(hello_escaped) > hello_unescaped "안녕하세요" encodeURI() > var hello = "안녕하세요" > var hello_encoded = encodeURI(hello) > hello_encoded "%EC%95%88%EB%85%95%ED%95%98%EC%84%B8%EC%9A%94" > var hello_decoded = decodeURI(hello_encoded) > hello_decoded "안녕하세요" However, Mozilla says that escape() is deprecated .

How do I replace a double-quote with an escape-char double-quote in a string using javascript?

有些话、适合烂在心里 提交于 2019-11-30 06:08:11
Say I have a string variable ( var str ) as follows- Dude, he totally said that "You Rock!" Now If I'm to make it look like as follows- Dude, he totally said that \"You Rock!\" How do I accomplish this using the JavaScript replace() function? str.replace("\"","\\""); is not working so well. It gives unterminated string literal error. Now, if the above sentence were to be stored in a SQL database, say in MySQL as a LONGTEXT (or any other VARCHAR -ish) datatype, what else string optimizations I need to perform? Quotes and Commas are not very friendly with query strings. I'd appreciate a few