Re: Changing STABLE DOCTYPE?

Paul Lesniewski <[email protected]> Tue, 3 Jan 2012 11:09:39 -0800
Newsgroups gmane.mail.squirrelmail.devel
Message-ID <CAHog116KDuHwf7cXWf61zErYqOGet+TbuVOXFQo8W_4QafHnxQ@mail.gmail.com>
>>>> I've been patching Squirrelmail for a long time now to make it run in
>>>> standards mode to fix things for Opera. I think it'd be great if
>>>> SquirrelMail did this by default.
>>>
>>> I'm going to propose a configuration setting so those who want to can
>>> change to standards mode.  Please try the attached patch (against
>>> version 1.4.23-svn) and let me know if there are any problems.
>
> I tested. The patch works fine and makes the option available when
> configuring. Setting it to true makes the pages have:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
>
> , which puts the pages in standards mode, which also avoids the Opera quirks
> mode font-size bug. I also didn't notice any issues with the display of
> messages or preference pages or message detail and message header plug-in
> pages etc.
>
> However, the transitional doctype (with the loose dtd URI specified) only
> triggers "almost standards mode" (see <http://hsivonen.iki.fi/doctype/>). A
> regular HTML 4.01 doctype with the strict dtd URI should trigger full
> standards mode. But, so will "<!DOCTYPE html>".  As mentioned on the page,
> the main difference between standards mode and almost standards mode is the
> handling of images and alignment. If it's not a problem, it'd be best to
> shoot for full standards mode (or allow the choice between quirks, almost
> standards and standards modes).

I suppose you're right; since SquirrelMail doesn't use any sliced
images, I didn't give much credence to the difference between
loose/strict.  I'm changing the patch to allow for quirks, almost
standards and standards.  I don't know as it makes much sense to allow
HTML5, but that could be added more easily to this scheme as well.

Please revert the last patch and try the one attached to this message.

Thank you.

-- 
Paul Lesniewski
SquirrelMail Team
Please support Open Source Software by donating to SquirrelMail!
http://squirrelmail.org/donate_paul_lesniewski.php

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev

-----
squirrelmail-devel mailing list
Posting guidelines: http://squirrelmail.org/postingguidelines
List address: [email protected]
List archives: http://news.gmane.org/gmane.mail.squirrelmail.devel
List info (subscribe/unsubscribe/change options): https://lists.sourceforge.net/lists/listinfo/squirrelmail-devel
squirrelmail_configurable_browser_rendering_mode_v2.diff (application/octet-stream, 5.9 KB)
Index: config/config_default.php
===================================================================
--- config/config_default.php	(revision 14257)
+++ config/config_default.php	(working copy)
@@ -722,7 +722,22 @@
  */
 $check_referrer = '';
 
+/**
+ * Rendering Mode (quirks/(almost) standards)
+ * 
+ * Control browser rendering mode (affects
+ * the DOCTYPE at the top of all pages):
+ *
+ * "quirks"    = quirks mode
+ * "almost"    = almost standards mode
+ * "standards" = standards mode
+ *
+ * @global string $browser_rendering_mode
+ * @since 1.4.23
+ */
+$browser_rendering_mode = 'quirks';
 
+
 /**
  * Themes
  *   You can define your own theme and put it in this directory.
Index: config/conf.pl
===================================================================
--- config/conf.pl	(revision 14255)
+++ config/conf.pl	(working copy)
@@ -360,6 +360,9 @@
 $disable_security_tokens = 'false'      if ( !$disable_security_tokens );
 $check_referrer = ''                    if ( !$check_referrer );
 
+# Added in 1.4.23
+$browser_rendering_mode = 'quirks'      if ( !$browser_rendering_mode );
+
 if ( $ARGV[0] eq '--install-plugin' ) {
     print "Activating plugin " . $ARGV[1] . "\n";
     if ( -d "../plugins/" . $ARGV[1]) {
@@ -556,6 +559,7 @@
         print "16. Only secure cookies if poss. : $WHT$only_secure_cookies$NRM\n";
         print "17. Disable secure forms         : $WHT$disable_security_tokens$NRM\n";
         print "18. Page referal requirement     : $WHT$check_referrer$NRM\n";
+        print "19. Browser rendering mode       : $WHT$browser_rendering_mode$NRM\n";
         print "\n";
         print "R   Return to Main Menu\n";
     } elsif ( $menu == 5 ) {
@@ -775,6 +779,7 @@
             elsif ( $command == 16 ) { $only_secure_cookies      = command316(); }
             elsif ( $command == 17 ) { $disable_security_tokens  = command317(); }
             elsif ( $command == 18 ) { $check_referrer           = command318(); }
+            elsif ( $command == 19 ) { $browser_rendering_mode   = command319(); }
         } elsif ( $menu == 5 ) {
             if ( $command == 1 ) { command41(); }
             elsif ( $command == 2 ) { $theme_css = command42(); }
@@ -2536,6 +2541,37 @@
 
 
 
+# browser_rendering_mode (since 1.4.23)
+sub command319 {
+    print "This option allows you to control the browser rendering mode for pages\n";
+    print "that SquirrelMail generates.  SquirrelMail has long rendered in \"quirks\"\n";
+    print "mode, but can usually work fine in \"standards\" mode.  However, it is\n";
+    print "possible that some third party plugins may break in \"standards\" mode.\n";
+    print "It's also possible to use \"almost standards\" mode if you so desire.\n";
+
+    $input = "";
+    while ( $input ne "quirks" && $input ne "almost" && $input ne "standards" ) {
+        print "\n";
+        print "Enter one of the following:\n";
+        print "\n";
+        print $WHT . "quirks" . $NRM . "    - Traditional SquirrelMail quirks mode\n";
+        print $WHT . "almost" . $NRM . "    - Almost standards mode\n";
+        print $WHT . "standards" . $NRM . " - Standards mode\n";
+        print "\n";
+
+        print "Browser rendering mode? [$WHT$browser_rendering_mode$NRM]: ";
+        $input = <STDIN>;
+        chomp($input);
+        if ( $input eq "" && ($browser_rendering_mode eq "quirks"
+         || $browser_rendering_mode eq "almost" || $browser_rendering_mode eq "standards" )) {
+            $input = $browser_rendering_mode;
+        }
+    }
+    return $input;
+}
+
+
+
 ####################################################################################
 #### THEMES ####
 sub command41 {
@@ -3586,6 +3622,7 @@
 
     # string
         print CF "\$check_referrer          = '$check_referrer';\n";
+        print CF "\$browser_rendering_mode  = '$browser_rendering_mode';\n";
 
         print CF "\n";
         print CF "\$config_location_base    = '$config_location_base';\n";
Index: functions/page_header.php
===================================================================
--- functions/page_header.php	(revision 14255)
+++ functions/page_header.php	(working copy)
@@ -24,13 +24,17 @@
     if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) {
         global $base_uri;
     }
-    global $theme_css, $custom_css, $pageheader_sent;
+    global $theme_css, $custom_css, $pageheader_sent, $browser_rendering_mode;
 
     // prevent clickjack attempts
 // FIXME: should we use DENY instead?  We can also make this a configurable value, including giving the admin the option of removing this entirely in case they WANT to be framed by an external domain
     header('X-Frame-Options: SAMEORIGIN');
 
-    echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' .
+    echo ($browser_rendering_mode == 'standards'
+       ? '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'
+       : ($browser_rendering_mode == 'almost'
+         ? '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
+         : /* "quirks" */ '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">')) .
          "\n\n" . html_tag( 'html' ,'' , '', '', '' ) . "\n<head>\n" .
          "<meta name=\"robots\" content=\"noindex,nofollow\">\n" .
          "<meta http-equiv=\"x-dns-prefetch-control\" content=\"off\">\n";
Index: doc/ChangeLog
===================================================================
--- doc/ChangeLog	(revision 14255)
+++ doc/ChangeLog	(working copy)
@@ -30,6 +30,10 @@
     "$ldap_abook_allow_listing = TRUE;" (without quotes) to
     config/config_local.php (previously, this required editing of a
     file).
+  - Added ability to control browser rendering mode (quirks versus
+    standards) - see the $browser_rendering_mode setting in
+    config/config.php or the "4. General Options ==> 19. Browser
+    rendering mode" setting in the configuration tool.
 
 Version 1.4.22 - 12 July 2011
 -----------------------------