html-entities

Rspec testing for html entities in page content

邮差的信 提交于 2019-12-21 07:30:10
问题 I'm writing a request spec and would like to test for the presence of the string "Reports » Aging Reports". I get an error (invalid multibyte char) if I put in the character in my matcher expression directly, so I tried this: page.should have_content("Reports » Aging Reports") This fails the test with the message: expected there to be content "Reports » Aging Reports" in "\n Reports » Aging Reports\n I've tried things like .html_safe with no success. Is there a way to test for text containing

Encode a high code point (> U+FFFF) to HTML entities

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 02:38:14
问题 I have an input string (URL-encoded): %F0%9F%98%8E which decoded is the emoji "😎". How can I convert this to the HTML-Code 😎 ? http://unicode.online-toolz.com/tools/unicode-html-entities-convertor.php this site is doing exactly what I need. 回答1: <?php function mb_ord($char, $encoding = 'UTF-8') { if ($encoding === 'UCS-4BE') { list(, $ord) = (strlen($char) === 4) ? @unpack('N', $char) : @unpack('n', $char); return $ord; } else { return mb_ord(mb_convert_encoding($char, 'UCS-4BE', $encoding),

htmlentities() makes Chinese characters unusable

血红的双手。 提交于 2019-12-19 08:01:12
问题 we have a web application where we allow users to enter their own html in a text area. We save that data to our database. When we load the html data into the text area, of course, we use htmlentities() before throwing the html data into the textarea. Otherwise users could save inside the textarea and our application would break when loading that into the textarea. this works great, except when entering Chinese characters (and probably other languages such as Arabic, Japanese). The

PHP XSS sanitization

删除回忆录丶 提交于 2019-12-18 03:39:21
问题 Questions: What are the best safe1(), safe2(), safe3(), and safe4() functions to avoid XSS for UTF8 encoded pages? Is it also safe in all browsers (specifically IE6)? <body><?php echo safe1($xss)?></body> <body id="<?php echo safe2($xss)?>"></body> <script type="text/javascript"> var a = "<?php echo safe3($xss)?>"; </script> <style type="text/css"> .myclass {width:<?php echo safe4($xss)?>} </style> . Many people say the absolute best that can be done is: // safe1 & safe2 $s = htmlentities($s,

Russian ruble symbol HTML code?

眉间皱痕 提交于 2019-12-17 18:13:21
问题 Since Russian central bank already approved the new symbol for Russian ruble, is there any HTML code for it? Or I need to use png images? 回答1: Since 16 June 2014 there is a letter in unicode: \u20bd representing RUB currency sign: ₽ So, the answer to the question: HTML entity which should be used for RUB sign is ₽ Though, I suppose currently not all fonts are capable of showing it. Ability to see the sign in browser generally depends on your system fonts. As of today my Mac OS web fonts are

htmlentities in PHP but preserving html tags

杀马特。学长 韩版系。学妹 提交于 2019-12-17 17:26:39
问题 I want to convert all texts in a string into html entities but preserving the HTML tags, for example this: <p><font style="color:#FF0000">Camión español</font></p> should be translated into this: <p><font style="color:#FF0000">Camión español</font></p> any ideas? 回答1: You can get the list of correspondances character => entity used by htmlentities, with the function get_html_translation_table ; consider this code : $list = get_html_translation_table(HTML_ENTITIES); var_dump($list); (You might

What Are The Reserved Characters In (X)HTML?

…衆ロ難τιáo~ 提交于 2019-12-17 16:52:31
问题 Yes, I've googled it, and surprisingly got confusing answers. One page says that < > & " are the only reserved characters in (X)HTML. No doubt, this makes sense. This page says < > & " ' are the reserved characters in (X)HTML. A little confusing, but okay, this makes sense too. And then comes this page which says < > & " © ° £ and non-breaking space ( &nbsp ) are all reserved characters in (X)HTML. This makes no sense at all, and pretty much adds to my confusion. Can someone knowledgeable,

Does html_entity_decode replaces   also? If not how to replace it?

谁说胖子不能爱 提交于 2019-12-17 15:51:26
问题 I have a situation where I am passing a string to a function. I want to convert   to " " (a blank space) before passing it to function. Does html_entity_decode does it? If not how to do it? I am aware of str_replace but is there any other way out? 回答1: Quote from html_entity_decode() manual: You might wonder why trim(html_entity_decode(' ')); doesn't reduce the string to an empty string, that's because the ' ' entity is not ASCII code 32 (which is stripped by trim()) but ASCII code 160 (0xa0)

Replace characters with HTML entities in java

孤者浪人 提交于 2019-12-17 14:53:17
问题 I want to replace certain characters with their respective HTML entities in an HTML response inside a filter. Characters include < , > , & . I can't use replaceAll() as it will replace all characters, even those that are part of HTML tags. What is the best approach for doing so? 回答1: From java you may try, Apache Commons Lang (legacy v2) StringEscapeUtils.escapeHtml(). or with commons-lang3: StringEscapeUtils.escapeHtml4(). Please note this also converts à to à & such 回答2: If you're using a

Decoding all HTML Entities

六眼飞鱼酱① 提交于 2019-12-17 07:51:26
问题 I'm looking for some function that will decode a good amount of HTML entities. Reason is I am working on some code to take HTML content and turning it into plain text, the issue that I have is a lot of entities do not get converted using HttpUtility.HtmlDecode . Some examples of entities I'm concerned about are  , &, ©. This is for .net 3.5 . 回答1: Then maybe you will need the HttpUtility .HtmlDecode?. It should work, you just need to add a reference to System.Web. At least this was the way in