Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3283696
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:04:16+00:00 2026-05-17T20:04:16+00:00

I am developing a MVC application with PHP that uses XML and XSLT to

  • 0

I am developing a MVC application with PHP that uses XML and XSLT to print the views. It need to be fully UTF-8 supported. I also use MySQL right configured with UTF8. My problem is the next.

I have a <input type="text"/> with a value like àáèéìíòóùú”><‘@#~!¡¿?. This is processed to add it to the database. I use mysql_real_escape_string($_POST["name"]) and then do MySQL a INSERT. This will add a slash \ before “ and ‘.

The MySQL database have a DEFAULT CHARACTER SET utf8 and COLLOCATE utf8_spanish_ci. The table field is a normal VARCHAR.

Then I have to print this on a XML that will be transformed with XSLT. I can use PHP on the XML so I echo it with <?php echo TexUtils::obtainSqlText($value_obtained_from_sql); ?>. The obtainSqlText() function actually returns the same as the $value processed, is waiting for a final structure.

One of the first things that I will need for the selected input is to convert > and < to &gt; and &lt; because this will generate problems with start/end tags. This will be done with <?php htmlspecialchars($string, ENT_QUOTES, "UTF-8"); ?>. This will also converts & to &amp;, “ to &quot; and ‘ to &#039;. This is a big problem: XSLT starts to fail because it doesn’t recognize all HTML special characters.

There is another problem. I’ve talked about àáèéìíòóùú”><‘@#~!¡¿? input but I will have some text from a CKEditor <textarea /> that the value will look like:

<p>
    <a href="http://stackoverflow.com/">àáèéìíòóùú"><'@#~!¡¿?</a>
</p>

How I’ve to manage this? At first, if I want to print this second value right I will need to use <xsl:value-of select="value" disable-output-escaping="yes" />. Will “><‘ print right?

So what I am really looking for is how I need to manage this values and how I’ve to print. I need to use something if is coming from a VARCHARthat doesn’t allows HTML and another if is a TEXT (for example) and allows HTML? I will need to use disable-output-escaping=”yes” everytime?

I also want to know if doing this I am really securing the query from XSS attacks.

Thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:04:16+00:00Added an answer on May 17, 2026 at 8:04 pm

    This will be done with <?php htmlspecialchars($string, ENT_QUOTES, "UTF-8"); ?>.

    Fine.

    This is a big problem: XSLT starts to fail because it doesn’t recognize all HTML special characters.

    It shouldn’t fail on htmlspecialchars() output, ever. &amp; is a predefined entity in XML and &#39; is a character reference which is always allowed. htmlspecialchars() should produce XML-compatible output, unlike the usually-a-mistake htmlentities(). What is the error you are seeing?

    <a href="http://stackoverflow.com/">àáèéìíòóùú"><'@#~!¡¿?</a>

    Urgh, an HTML rich text editor produced that invalid markup? What a dodgy editor.

    If you have to allow users to input arbitrary HTML, it’s going to need some processing. Unless you really trust those users, you’ll need a purifier (to stop them using dangerous scripting elements and XSS-ing each other), and a tidier (to remove malformed markup either due to crap rich-text-editor output or deliberate sabotage). If you intend to put the content directly into XML you will also need it to convert to XHTML output and replace HTML entity references.

    A simple way to do this in PHP would be DOMDocument->loadHTML followed by a walk of the DOM tree removing all but known-good elements/attributes/URL-schemes, followed by DOMDocument->saveXML.

    Will "><' print right?

    Well, it’ll print as in your example, yes. But that’s equally invalid as both HTML and XML.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an application using MVC Preview 5. I have used typed views.
I've started developing a forum application in PHP on my MVC Framework and I've
I am developing an ASP.NET MVC application and I want to use OpenId. What
I am in the process of developing a large ASP.NET MVC application. I am
Hi I am developing a simple application based upon ASP.NET MVC. I have altered
On an ASP.NET MVC (Beta) site that I am developing sometimes calls to ActionLink
I am currently developing a PHP MVC Framework for a personal project. While I
i'm developing a web application that focus heavily on ajax. the whole application is
I'm developing an ASP.Net MVC site and on it I list some bookings from
I've been developing a site using ASP.NET MVC, and have decided to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.