Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/misc.c

    rc6ca3ee r0f64ca7  
    4747#endif
    4848
     49#include "md5.h"
    4950#include "ssl_client.h"
    5051
     
    7879}
    7980
     81time_t mktime_utc( struct tm *tp )
     82{
     83        struct tm utc;
     84        time_t res, tres;
     85       
     86        tp->tm_isdst = -1;
     87        res = mktime( tp );
     88        /* Problem is, mktime() just gave us the GMT timestamp for the
     89           given local time... While the given time WAS NOT local. So
     90           we should fix this now.
     91           
     92           Now I could choose between messing with environment variables
     93           (kludgy) or using timegm() (not portable)... Or doing the
     94           following, which I actually prefer...
     95           
     96           tzset() may also work but in other places I actually want to
     97           use local time.
     98           
     99           FFFFFFFFFFFFFFFFFFFFFUUUUUUUUUUUUUUUUUUUU!! */
     100        gmtime_r( &res, &utc );
     101        utc.tm_isdst = -1;
     102        if( utc.tm_hour == tp->tm_hour && utc.tm_min == tp->tm_min )
     103                /* Sweet! We're in UTC right now... */
     104                return res;
     105       
     106        tres = mktime( &utc );
     107        res += res - tres;
     108       
     109        /* Yes, this is a hack. And it will go wrong around DST changes.
     110           BUT this is more likely to be threadsafe than messing with
     111           environment variables, and possibly more portable... */
     112       
     113        return res;
     114}
     115
    80116typedef struct htmlentity
    81117{
     
    89125        { "gt",     ">" },
    90126        { "amp",    "&" },
     127        { "apos",   "'" },
    91128        { "quot",   "\"" },
    92129        { "aacute", "á" },
     
    269306        for( i = j = 0; t[i]; i ++, j ++ )
    270307        {
    271                 /* if( t[i] <= ' ' || ((unsigned char *)t)[i] >= 128 || t[i] == '%' ) */
    272                 if( !isalnum( t[i] ) )
     308                if( !isalnum( t[i] ) && !strchr( "._-~", t[i] ) )
    273309                {
    274310                        sprintf( s + j, "%%%02X", ((unsigned char*)t)[i] );
Note: See TracChangeset for help on using the changeset viewer.