Attachment Details
Not logged in
Overview

Artifact ID: 5c7f1e7a0ecfe359ce4986836f4d3a0a0ea53c64
Ticket: 9fbc3fad8a30180effa7b55fc496e28987c6d98f
Date: 2011-04-22 03:10:51
User: anonymous
Artifact Attached: 0b74a6e5b49689cc7bac9de29a03f623b17d1883
Filename:xhtmlpatch.diff.txt
Description:Patch to send content type application/xhtml+xml to the browser when appropriate.
Content Appended
     1  Index: src/cgi.c
     2  ===================================================================
     3  --- src/cgi.c
     4  +++ src/cgi.c
     5  @@ -667,10 +667,16 @@
     6   */
     7   void cgi_init(void){
     8     char *z;
     9     const char *zType;
    10     int len;
    11  +
    12  +  z = (char *)P("HTTP_ACCEPT");
    13  +  if( z  && strstr(z, "application/xhtml+xml") ){
    14  +    cgi_set_content_type("application/xhtml+xml");
    15  +  }
    16  +
    17     cgi_destination(CGI_BODY);
    18     z = (char*)P("QUERY_STRING");
    19     if( z ){
    20       z = mprintf("%s",z);
    21       add_param_list(z, '&');
    22  @@ -1027,10 +1033,12 @@
    23         cgi_setenv("HTTP_HOST", zVal);
    24       }else if( strcmp(zFieldName,"if-none-match:")==0 ){
    25         cgi_setenv("HTTP_IF_NONE_MATCH", zVal);
    26       }else if( strcmp(zFieldName,"if-modified-since:")==0 ){
    27         cgi_setenv("HTTP_IF_MODIFIED_SINCE", zVal);
    28  +    }else if( strcmp(zFieldName,"accept:")==0 ){
    29  +      cgi_setenv("HTTP_ACCEPT", zVal);
    30       }
    31   #if 0
    32       else if( strcmp(zFieldName,"referer:")==0 ){
    33         cgi_setenv("HTTP_REFERER", zVal);
    34       }else if( strcmp(zFieldName,"user-agent:")==0 ){
    35  
    36  Index: src/style.c
    37  ===================================================================
    38  --- src/style.c
    39  +++ src/style.c
    40  @@ -18,11 +18,11 @@
    41   ** This file contains code to implement the basic web page look and feel.
    42   **
    43   */
    44   #include "config.h"
    45   #include "style.h"
    46  -
    47  +#include <ctype.h>
    48   
    49   /*
    50   ** Elements of the submenu are collected into the following
    51   ** structure and displayed below the main menu by style_header().
    52   **
    53  @@ -105,10 +105,15 @@
    54     Th_Store("compiler_name", COMPILER_NAME);
    55     if( g.zLogin ){
    56       Th_Store("login", g.zLogin);
    57     }
    58     if( g.thTrace ) Th_Trace("BEGIN_HEADER_SCRIPT<br />\n", -1);
    59  +  while( isspace(*zHeader) ){ ++zHeader; }
    60  +  if( strncmp(zHeader, "<html>", 6)==0 ) {
    61  +    Th_Render("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
    62  +    zHeader += 6;
    63  +  }
    64     Th_Render(zHeader);
    65     if( g.thTrace ) Th_Trace("END_HEADER<br />\n", -1);
    66     Th_Unstore("title");   /* Avoid collisions with ticket field names */
    67     cgi_destination(CGI_BODY);
    68     g.cgiOutput = 1;
    69  
    70  Index: src/translate.c
    71  ===================================================================
    72  --- src/translate.c
    73  +++ src/translate.c
    74  @@ -107,10 +107,15 @@
    75         for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
    76           if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
    77              omitline = 1; break; 
    78           }
    79           if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
    80  +        if( strncmp(zLine+i, "<html>", 6)==0 ){
    81  +          strcpy(zOut+j, "<html xmlns=\\\"http://www.w3.org/1999/xhtml\\\">");
    82  +          i += 6;
    83  +          j += 45;
    84  +        }
    85           zOut[j++] = zLine[i];
    86         }
    87         while( j>0 && isspace(zOut[j-1]) ){ j--; }
    88         zOut[j] = 0;
    89         if( j<=0 && omitline ){
    90