htmlspecialchars

php XML DOM translates special chars to &#xYY;

匆匆过客 提交于 2020-01-01 16:24:09
问题 I send this with AJAX POST: <li><ul class "zone zCentral ui-sortable"><li><ul class="region rCol3 ui-sortable"><li class="" style=""><div><span class="tc tc_video">574081</span> <span>video: 'Mundo.Hoy': ¿Dónde habré olvidado... mi memoria?</span></div></li></ul></li></ul></li> I do this to create XML: header('Content-type: text/html; charset=utf-8'); if(isset($_POST) && isset($_POST['data'])) { $data = '<ul id="zone_container" class="ui-sortable">'; $data .= $_POST['data']; $data .= '</ul>';

is it better to escape/encode the user input before storing it to database or to store it as it is in database and escape it while retrieving?

家住魔仙堡 提交于 2019-12-30 22:27:15
问题 I am using htmlspecialchars() function to prevent XSS attacks. I have doubt regarding what is the better method to store the data in database from following. Method 1 : Store the user input values after applying htmlspecialchars() function. Using this it user input "<script>" will become "<script>" . Method 2 : Store the user input as it is and apply htmlspecialchars() method while retrieving the data and displaying it on the page. The reason for my doubt is that I believe using method 1

how to convert new line and html code in htmlspecialchars in php

大憨熊 提交于 2019-12-30 16:06:10
问题 here is my string hello world <textarea>hello world</textarea> how can I convert this string hello   world     <textarea>hello world</textarea> in php. Any one help please... I am try htmlspecialchars(); function but that doesn't work perfect. 回答1: please read more on php ..Maybe this can help you https://www.w3schools.com/pHp/default.asp <?php echo "hello"; echo "</br>"; echo "world"; echo "</br>"; echo "</br>"; echo "<input type = 'textare' value = 'hello world'>"; ?> 来源: https:/

Using HTML Purifier on a site with only plain text input

不想你离开。 提交于 2019-12-30 13:58:12
问题 I would appreciate an answer to settle a disagreement between me and some co-workers. We have a typical PHP / LAMP web application. The only input we want from users is plain text. We do not invite or want users to enter HTML at any point. Form elements are mostly basic input text tags. There might be a few textareas, checkboxes etc. There is currently no sanitizing of output to pages. All dynamic content, some of which came from user input, is simply echoed to the page. We obviously need to

Using HTML Purifier on a site with only plain text input

筅森魡賤 提交于 2019-12-30 13:58:10
问题 I would appreciate an answer to settle a disagreement between me and some co-workers. We have a typical PHP / LAMP web application. The only input we want from users is plain text. We do not invite or want users to enter HTML at any point. Form elements are mostly basic input text tags. There might be a few textareas, checkboxes etc. There is currently no sanitizing of output to pages. All dynamic content, some of which came from user input, is simply echoed to the page. We obviously need to

Avoiding double encoding in <INPUT> while using htmlspecialchars

痴心易碎 提交于 2019-12-25 05:32:37
问题 Say you have a text <INPUT> for a user's name and they decide to type in Johnny's Pizza This is saved in DB as Johnny's Pizza But if the user decides to edit, I repopulate the text <INPUT> as follows echo form_input('name', htmlspecialchars($name, ENT_QUOTES, 'UTF-8')); which will show as Johnny's Pizza inside the input field. PHP.net has a comment here suggesting to use echo form_input('name', htmlspecialchars($name, ENT_QUOTES, 'UTF-8', FALSE)); that is, FALSE referring to $double_encoding

PHP - htmlspecialchars and UTF-8

自古美人都是妖i 提交于 2019-12-24 03:35:24
问题 I am just trying to confirm something with htmlspecialchars. I have just converted my database into UTF-8, and I think I finally have it all working, but throughout my code I have used the PHP htmlspecialchars function: htmlspecialchars($val, ENT_QUOTES,'ISO-8859-1',false); Do I need to worry about changing all the entries to: htmlspecialchars($val, ENT_QUOTES,'UTF-8',false); The PHP documention suggests I don't need to, but is that true? For the purposes of this function, the charsets ISO

help to get rid of HTML special chars in database

与世无争的帅哥 提交于 2019-12-24 00:44:59
问题 I've migrated my site from interspire CMS to Joomla! CMS. I've managed to migrate all the database of articles, but some of them have a weird issue - when I access the page from joomla, the title contains HTML entities like ’ . As you can guess from the CMS's I use, I rely on PHP as my server side, and MySql for my database. I tried to go over the titles of the articles in the database with htmlspecialchars_decode AND html_entity_decode in order to get rid of those, but it had no effect. if I

htmlspecialchars outputting blank

北城以北 提交于 2019-12-23 09:35:00
问题 Using both htmlspecialchars and htmlentities is causing blank outputs from items such as a ™ symbol and even single ' quotes. Obviously, this is absolutely useless, however outputting the data without using html characters results in this symbol for both �. Any reason why this is occuring? here is the code that is causing the problem: <p> <?php echo nl2br(htmlspecialchars($aboutarray[0]['about_us'], ENT_COMPAT, "UTF-8")); ?> </p> 回答1: That string is not encoded in valid UTF-8 encoding. It

How do I convert special characters using java?

…衆ロ難τιáo~ 提交于 2019-12-23 07:46:26
问题 I have strings like: Avery® Laser & Inkjet Self-Adhesive I need to convert them to Avery Laser & Inkjet Self-Adhesive. I.e. remove special characters and convert html special chars to regular ones. 回答1: Avery® Laser & Inkjet Self-Adhesive First use StringEscapeUtils#unescapeHtml4() (or #unescapeXml(), depending on the original format) to unescape the & into a & . Then use String#replaceAll() with [^\x20-\x7e] to get rid of characters which aren't inside the printable ASCII range. Summarized