Changeset 4c30f2f6ffcd958c2364f1fa1e90b2ddcfef173d

Show
Ignore:
Timestamp:
02/18/10 22:20:12 (5 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1266531612 +0000
git-parent:

[a1d250980c50e88be7098fda4f74a0acb7fb61a7]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1266531612 +0000
Message:

fixes #260

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/stratcon_realtime_http.c

    r3d36f5a r4c30f2f  
    4747#include "stratcon_datastore.h" 
    4848 
     49#include <ctype.h> 
    4950#include <unistd.h> 
    5051#include <assert.h> 
     
    193194    memset(&iter, 0, sizeof(iter)); 
    194195    while(noit_hash_next(&json, &iter, &key, &klen, &vval)) { 
     196      char *val = (char *)vval; 
    195197      if(i++) ra_write(",", 1); 
    196198      ra_write("'", 1); 
    197199      ra_write(key, klen); 
    198       ra_write("':'", 3); 
    199       ra_write((char *)vval, strlen((char *)vval)); 
    200       ra_write("'", 1); 
     200      ra_write("':\"", 3); 
     201      while(*val) { 
     202        if(*val == '\"' || *val == '\\') { 
     203          ra_write((char *)"\\", 1); 
     204        } 
     205        if(isprint(*val)) { 
     206          ra_write((char *)val, 1); 
     207        } 
     208        else { 
     209          char od[5]; 
     210          snprintf(od, sizeof(od), "\\%03o", *((unsigned char *)val)); 
     211          ra_write(od, strlen(od)); 
     212        } 
     213        val++; 
     214      } 
     215      ra_write("\"", 1); 
    201216    } 
    202217    snprintf(buffer, sizeof(buffer), "});</script>\n");