Fork me on GitHub

HTML Validator  Bottom

  • I've been cleaning up a few modules and now nearly everything is validated XHTML1.1 compliant. Yee haw!!!

    But, what I can't get to validate is a lot of user-submitted HTML, such as news, reviews, etc.

    Anybody know of anything out there that users could use to validate their HTML before allowing them to submit? Perhaps we could run their "preview" through the W3 validator....any ideas?

    Slugger
  • http://tidy.sourceforge.net/

    - if using XHTML do you use the appropriate mime type 'application/xhtml+xml), too [1]?
    - did you check your site with a 'schema-validator' [2]
    (BTW: i've just ported both krapohl.info and PN-cms.de to XHTML 1.0 strict under application/xhtml+xml for QA of postnuke .76 icon_wink )

    [1] http://www.hixie.ch/advocacy/xhtml
    [2] http://www.schneegans.de/sv

    --
    regards from germany
    ..::[Zikula Application Framework]::.. ..::[SEO-Blog]::.. ..::[CMS Sicherheit]::..
  • Talk about stealing one's thunder! :?


    Thanks for the tidy reference...now the question is how do I get it to work with my PN submissions???? Are you using it?

    As for mime, I found this:

    Code

    $charset = "iso-8859-1";
    $mime = "text/html";
    function fix_code($buffer) {
    return (preg_replace("!\s*/>!", ">", $buffer));
    }
    if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) {
            if(preg_match("/application\/xhtml\+xml;q=([01]|0\.\d{1,3}|1\.0)/i",$_SERVER["HTTP_ACCEPT"],$matches)) {
                $xhtml_q = $matches[1];
                    if(preg_match("/text\/html;q=q=([01]|0\.\d{1,3}|1\.0)/i",$_SERVER["HTTP_ACCEPT"],$matches)) {
                        $html_q = $matches[1];
                            if((float)$xhtml_q >= (float)$html_q) {
                            $mime = "application/xhtml+xml";
                }
                    }
            } else {
                $mime = "application/xhtml+xml";
                    }
    }
    if($mime == "application/xhtml+xml") {
        $prolog_type = "<?xml version=\"1.0\" encoding=\"$charset\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
    } else {
        ob_start("fix_code");
            $prolog_type = "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html lang=\"en\">\n";
    }
    header("Content-Type: $mime;charset=$charset");
    header("Vary: Accept");
    print $prolog_type;


    ...and no, I couldn't get the schema-validated under 1.1 (not supported) but I have as 1.0. Thanks for the reference.

    I wasn't able to validate krapohl.info or PN-cms.de either so I guess I shouldn't feel too bad. wink

    Still, it's not surprising to learn that you're way out ahead of me on this....but, as you did when you introduced PN-cms.de without tables, you've given me incentive to keep going at it. (BTW info I've pulled from the forums at PN-cms.de has been a "life saver" on more than one occasion.)

    Finally, I'd like to say how grateful I am to everyone (particularly Mark and you) who cleaned up the core to the point that this exercise is even possible. :)


    Slugger
  • one of youz guyz should develop that into a hook-module that can pass through the 'preview' stage of submit story...
  • Quote

    As for mime, I found this:
    [...]

    i use a quite similiar snippet as a theme plugin to set the correct mime type for the 'advanced' browsers (IE still can display XHTML), see http://www.pn-cms.de/themes/pnMain/plugins/function.contenttype.php.txt (still some work to do). there's a minor problem within administration due to not 'well-formed' links in an admin-template that can't be overridden with a theme template due to include paths but this is already on the list...

    Quote

    I wasn't able to validate krapohl.info or PN-cms.de either so I guess I shouldn't feel too bad.

    due to various accessibility reasons (e.g. deprecated lang attribute) i stick with XHTML 1.0:
    schema validation for krapohl.info
    schema validation for pn-cms.de

    Quote

    one of youz guyz should develop that into a hook-module that can pass through the 'preview' stage of submit story...

    already thought of something like this but i didn't find a tidy-(PHP)-class yet. it's one of the basic parts for an atag compliant CMS...

    --
    regards from germany
    ..::[Zikula Application Framework]::.. ..::[SEO-Blog]::.. ..::[CMS Sicherheit]::..
  • Thanks larsneo, I needed that plugin! ;)

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • Dah...a Xanthia plugin...why didn't I think of that? Thanks!

This list is based on users active over the last 60 minutes.