• Hi!
    I noticed today that my blog isn’t validating as XHTML 1.0 Transitional, and it seems to be a problem with the ampersands (&) in a couple of URLs I have posted.
    This is the error reported by the validator:
    “Line 139, column 134: cannot generate system identifier for general entity “tag”
    …ge/2100-1032_3-5245523.html?part=rss&tag=5245523&subj=news.1032.5″ rel=”exter
    An entity reference was found in the document, but there is no reference by that name defined. Often this is caused by misspelling the reference name, unencoded ampersands, or by leaving off the trailing semicolon (;). The most common cause of this error is unencoded ampersands in URLs as described by the WDG in “Ampersands in URLs”.
    Entity references start with an ampersand (&) and end with a semicolon (;). If you want to use a literal ampersand in your document you must encode it as “&” (even inside URLs!). Be careful to end entity references with a semicolon or your entity reference may get interpreted in connection with the following text. Also keep in mind that named entity references are case-sensitive; &Aelig; and æ are different characters.
    Note that in most documents, errors related to entity references will trigger up to 5 separate messages from the Validator. Usually these will all disappear when the original problem is fixed.”

    The way to solve this is change the & in the URL to & … Is there a way to get WordPress to do this automatically?
    Thanks!

Viewing 13 replies - 1 through 13 (of 13 total)
  • Automatically where? I mean, if you happen to put a link into your html, no. 😉
    It does cleaning on some things, but I don’t know if there’s a general cleaner. For CG-Feedread, I had to do a lot of cleanup to not only URLs but the title fields as well, as there are a lot of feeds out there feeding out ‘invalid’ data, that isn’t XHTML compliant — you have to clean it yourself.
    -d

    posts_nav_link() is fixed in CVS.

    Thread Starter Jem

    (@jem)

    Ahhh OK, thanks for the replies. 🙂

    Still invalid. 🙁

    http://validator.w3.org/check?uri=http%3A%2F%2Fwww.war59312.com%2Findex.php%3Fs%3Dd%26submit%3DSearch%26paged%3D7&charset=%28detect+automatically%29&doctype=Inline

    Caused by:

    <div class="navigation">
    <div class="alignleft"><?php posts_nav_link('','','&laquo; Older Entries') ?></div>
    <div class="alignright"><?php posts_nav_link('','Newer Entries &raquo;','') ?></div>
    </div>

    It creats the darn urls with & instead of &amp; . 🙁

    Anyone know how to fix?

    Pump, been like three weeks, guess no one has any idea?

    Thanks,

    Will

    PS: Will only pump this once so please dont get mad. 😉

    S’okay, it’s just that anyone looking just at the top of the thread is seeing a two year old topic.

    How about posting a new thread so someone with more thoughts than I have about this might really SEE it?

    [And please just link to the blog in question, no need to include a humungously long validator link…. thanks!]

    war59312, the w3 validator is reporting this line from that page as invalid due to the ampersand in the url:

    <a href="http://www.war59312.com/wp-register.php">Register</a> <input type="hidden" name="redirect_to" value="/index.php?s=d&submit=Search&paged=7"/></div>

    Also, when looking at the source of the page being validated, ampersands are converted in the previous/next page links.

    I’ve the & problem with my site too although it still validate but its rendering some errors due to this code from wp grins, any idea how to fix that too?

    link to validator results

    Line 114 column 43: character “&” is the first character of a delimiter but occurred as data.

    ... (document.getElementById('content') && document.getElementById('content').ty

    thank you. 🙂

    Truth, the <script> element should be enclosed in comment tags, both to hide the code from browsers which do not support <script> (yes, rare these days), and for validation purposes. So starting:

    <script type="text/javascript">
    <!--
    function grin(tag) {

    and ending:

    }
    //-->
    </script>

    Alternatively you can define it as a CDATA section:

    <script type="text/javascript">
    <![CDATA[
    function grin(tag) {

    }
    ]]>
    </script>

    Thanks for the help, Kafkaesqui. That did it 🙂

    Hey,

    OK vkaryl will do next time.

    OMG I’m blind. lol

    Thanks Kafkaesqui. I dont know what I was thinking.

    Its caused by REQUEST_URI and when the url itcludes the & it scews it up. 🙁

    Take Care,

    Will

    war59312, try something like this in your code:

    echo convert_chars($_SERVER['REQUEST_URI']);

    Sweet, thanks a ton Kafkaesqui! Pefect! 🙂

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Convert ampersands in URLs?’ is closed to new replies.