htmlspecialchars

php htmlspecialchars() from one form to another

Why can't htmlspecialchars() continually encode characters after each form submission? Take a look at the following example: <?php $_POST['txt'] = htmlspecialchars($_POST['txt']); ?> <form method="post"> <input name="txt" value="<?=$_POST['txt'] ?>" /> <input type="submit" name="save" value="test" /> </form> You can see it at running...

Do you only run htmlspecialchars() on output or is there other functionality you also do?

When outputting user input, do you only use htmlspecialchars() or are there are functions/actions/methods you also run? I'm looking for something that will also deal with XSS. I'm wondering if I should write a function that escapes user input on output or just use htmlspecialchars(). I'm looking for the generic cases, not the specific c...

convert html characters back to text in Flash - AS3

I need to generate an editable xml file to supply content to a flash website. I am generating my file with a html form, and htmlspecialchars e.g.: $currentItem = htmlspecialchars(stripslashes($currentItem)); This is to prevent xml entries which would produce the error "XML Parsing Error: not well-formed", such as <entry title=...

Weird characters being saved in my database...

Here is a screen shot of weird characters in my database. I know that this character combination is for a crazy apostrophe. Should I just let these characters stay in my database? Or should I strip them out and replace with normal apostrophes? If I should strip, is there on ruby function to ensure that all characters that save to my d...

Is there a Python equivalent to the PHP function htmlspecialchars() ?

Is there a similar or equivalent function in Python to the PHP function htmlspecialchars()? The closest thing I've found so far is htmlentitydefs.entitydefs(). ...

Using mysql_real_escape_string and htmlspecialchars in cakephp?

Hello, I am using FCKEditor with CakePHP and when I save data sent from the editor I want to run the htmlspecialchars() and mysql_real_escape_string() functions on the data to clean it before I store it in my database. The problem is I am not really sure where to do this within the CakePHP framework. I tried in the controller like thi...

User Input filtering in PHP

Hello guys, Am currently working on an application that requires users to submit posts and comments which is displayed on the site. As we all know that user input can't be trusted so i used htmlspecialchars($string,ENT_QUOTES) to process user's posts and comments. Now, i want some certain html tags ignored. such as <b><br /> and a few...

PHP htmlspecialchars error

why would this $trader_details = array_walk($trader_details, 'htmlspecialchars'); give this error? Severity: Warning Message: htmlspecialchars() expects parameter 2 to be long, string given afaik htmlspecialchars only has optional parameters apart from the input string? this running in codeigniter thx ...

How to convert with Ruby accented characters in HTML special entities

How can I do this on Ruby? puts some_method("ò") # => "&ograve;" In other words convert an accented character like ò to his HTML version: &ograve; I tried like this: # coding: utf-8 require 'rubygems' require 'htmlentities' require 'unicode' coder = HTMLEntities.new string = "Scròfina" puts coder.encode(string, :named) but what I...

php htmlspecialchars and utf-8

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 : htmlspec...

Adding 'utf-8' parameter to occurances of htmlspecialchars() - can it break anything?

Assuming my project is utf-8 throughout and has always been used with utf-8 encoding, is there anything legit that could possibly break if I change all occurances of htmlspecialchars($var) to htmlspecialchars($var, ENT_QUOTES, 'utf-8')? I do know one thing: Obviously, ENT_QUOTES differs from ENT_COMPAT in that it also escapes single quo...

How do I convert special characters using java?

I have strings like: Avery® Laser &amp; 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. ...

special html characters are not rendered correctly in the browser

I am storing pieces of XHTML as text on a search index. Once the user submits a search request, I insert this text in my page and return it to the server. This all works fine except when there is a ISO 8859-1 Symbol in the text (such as a copyright symbol ©). The symbol is not represented correctly in the browser, it is displayed as t...

is it possible to decode special HTML entities in Objective C (for iPhone)?

could you show me algorithm for implement decode special HTML entities in Objective C? any idea? ...

How to Remove Html Tags in PHP ?

I use htmlspecialchars function in my string. But, I don't want to clean them; <b>, <br>, <p> <ul>,<li> bla bla... Example: Mystring = "<script>.....</script><br><b>test</b><p>aaaa</p>"; I want to; = ..... ...

How to retrieve an input's value without the browser interpreting html special entities?

Is there a way in JavaScript or MooTools to retrieve the actual text in the value from an input element without the browser interpreting any html special entites? Please see the example included below. My desired outcome is: <div id="output"> <p>Your text is: <b>[&lt;script&gt;alert('scrubbed');&lt;/script&gt;]</b></p> </div> Not...

Why htmlspecialchars_decode in PHP does not have the charset parameter as in its counterpart?

There is a charset parameter in htmlspecialchars but the decode version does not have it. In comparison to the similar htmlentities, the encode and decode functions both have the charset parameter. So I can't choose what charset I am decoding back to? ...

[CakePHP] htmlspecialchars

hi all, if i submit data like my string using form on insert/edit view, on a list view i'll get my string as italic (like here). how can i avoid that, and to have my string (with visible all html tags) on all forms? i.e. so it appears like this: <i>my string</i> thanks in advance! ...

Why is htmlspecialchars adding slashes to my webpage?

I have my input placed into mySQL through a PDO prepared statement, and have it placed in my website with PHP using htmlspecialchars() to protect against XSS. Only problem is now I get slashes, before any quotes, that are visible on the webpage to the user it only happens when I upload it to the server. Never happens on my localhost. Wh...

JSON specialchars JSON php 5.2.13

I'm getting crazy over these encoding probs... I use json_decode and json_encode to store and retrieve data. What I did find out is, that json always needs utf-8. No problem there. I give json 'hellö' in utf-8, in my DB it looks like hellu00f6. Ok, codepoint. But when I use json_decode, it won't decode the codepoint back, so I still hav...