Jump to content

Purpose of not validating & (ampersand) in xthml strict?


vineld

Recommended Posts

What is the actual purpose of not letting ampersands (&) pass through in xhtml strict? Since I usually use this format in my work it makes my life so much more painful. I don't use & very often though since it does not regularly appear in well written text (with certain exceptions that is) and my urls are mostly user friendly except for admin pages and then I don't really care if it validates or not.

 

However, when printing database values I always need to replace & with & which sucks big time as it's a completely unnecessary operation and trying to build as efficient applications as possible that is not on my wishlist. I really don't want to save & as & in the database.

 

Is there an easier way for me to get rid of this annoying issue?

Link to comment
Share on other sites

Twisting words  :D For me making sure that I get what I want is validation, no matter what I look for.

 

Perhaps this is just a mistunderstanding. Could you give me some example of those scenarios where it will be necessary to filter database values where it can not easily be done prior to insertion?

Link to comment
Share on other sites

I don't understand your question, but say that $post is an array holding information about a forum post, like the one I'm writing now.

 

That is just raw information, and it can be represented or output in a variety of manners. In HTML I might display the post like this:

<?php echo nl2br(htmlentities($post['body'])) ?>

 

Another scenario might be that I was writing some AJAX and wanted to get the post via a backend API, so I might do something like this instead:

echo json_encode($post);

 

So depending on how I want to use it, the way I'll filter and manipulate the data is different.

Link to comment
Share on other sites

Alright, when put that way I will have to agree with you  ;) There are situations where the border between filtering and validation is very thin though. Most data stored in databases are plain text or numbers though and then I will not want any unnecessary operations on display. Of course a forum post or WYSIWYG content is a bit more complex to handle.

 

I think we are on the same page after all  ;) In my defense, I haven't slept much lately  :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.