Re: Changing STABLE DOCTYPE?

Paul Lesniewski <[email protected]> Mon, 2 Jan 2012 15:02:20 -0800
Newsgroups gmane.mail.squirrelmail.devel
Message-ID <CAHog114Ug2vM0DOws8XGFJZVMC+6F7Tfh2ivzFFUR04RGB-QMA@mail.gmail.com>
On Mon, Jan 2, 2012 at 1:34 AM, Michael A. Puls II <[email protected]> wrote:
> On Fri, 30 Dec 2011 15:42:31 -0500, Paul Lesniewski <[email protected]>
> wrote:
>
>>  SquirrelMail version 1.4.x renders in "quirks" mode, and ideally
>> we'd render in "standards" mode.
>>
>>  Opinions?
>
>
> Opera has a quirks mode font-size regression bug that makes the body text
> bigger compared to other browsers. I've been trying to get Opera to fix it
> for years but they just won't do it. :(
>
> Opera has <opera:config#browser%20css%20file> where you can patch Opera's
> default style sheet. However, browser.css doesn't have any way to
> differentiate between quirks mode and standards mode. So, if you fix the
> font-size for quirks mode, you'll break something in standards mode and vice
> versa.
>
> I asked the Opera devs if they'd implement something for browser.css to
> differentiate between quirks mode and standards mode so users could at least
> fix it themselves and they said it could be easily implemented. But, the
> whole proposal was denied.
>
> In short, there's no way to fix it for Opera except for making the page run
> in standards mode or by using user css or user js in a site preference.
>
> 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.

Thanks.

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

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox

-----
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.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,20 @@
  */
 $check_referrer = '';
 
+/**
+ * Rendering Mode (quirks versus standards)
+ * 
+ * Control browser rendering mode:
+ *
+ * true = standards Mode
+ * false = quirks Mode
+ *
+ * @global bool $standards_mode_rendering
+ * @since 1.4.23
+ */
+$standards_mode_rendering = false;
 
+
 /**
  * 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
+$standards_mode_rendering = 'false'     if ( !$standards_mode_rendering );
+
 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. Standards mode rendering     : $WHT$standards_mode_rendering$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 ) { $standards_mode_rendering = command319(); }
         } elsif ( $menu == 5 ) {
             if ( $command == 1 ) { command41(); }
             elsif ( $command == 2 ) { $theme_css = command42(); }
@@ -2536,6 +2541,31 @@
 
 
 
+# standards_mode_rendering (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 "\n";
+
+    if ( lc($standards_mode_rendering) eq 'true' ) {
+        $default_value = "y";
+    } else {
+        $default_value = "n";
+    }
+    print "Render in \"standards\" mode? (y/n) [$WHT$default_value$NRM]: $WHT";
+    $standards_mode_rendering = <STDIN>;
+    if ( ( $standards_mode_rendering =~ /^y\n/i ) || ( ( $standards_mode_rendering =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+        $standards_mode_rendering = 'true';
+    } else {
+        $standards_mode_rendering = 'false';
+    }
+    return $standards_mode_rendering;
+}
+
+
+
 ####################################################################################
 #### THEMES ####
 sub command41 {
@@ -3581,14 +3611,17 @@
         print CF "\$session_name = '$session_name';\n";
 
     # boolean
-        print CF "\$only_secure_cookies     = $only_secure_cookies;\n";
-        print CF "\$disable_security_tokens = $disable_security_tokens;\n";
+        print CF "\$only_secure_cookies      = $only_secure_cookies;\n";
+        print CF "\$disable_security_tokens  = $disable_security_tokens;\n";
 
     # string
-        print CF "\$check_referrer          = '$check_referrer';\n";
+        print CF "\$check_referrer           = '$check_referrer';\n";
 
+    # boolean
+        print CF "\$standards_mode_rendering = $standards_mode_rendering;\n";
+
         print CF "\n";
-        print CF "\$config_location_base    = '$config_location_base';\n";
+        print CF "\$config_location_base     = '$config_location_base';\n";
 
         print CF "\n";
         print CF "\@include SM_PATH . 'config/config_local.php';\n";
Index: functions/page_header.php
===================================================================
--- functions/page_header.php	(revision 14255)
+++ functions/page_header.php	(working copy)
@@ -24,13 +24,15 @@
     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, $standards_mode_rendering;
 
     // 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 ($standards_mode_rendering
+       ? '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
+       : '<!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 $standards_mode_rendering setting in
+    config/config.php or the "4. General Options ==> 19. Standards mode
+    rendering" setting in the configuration tool.
 
 Version 1.4.22 - 12 July 2011
 -----------------------------