Ignore:
Timestamp:
May 10, 2007 8:00:44 PM (17 years ago)
Author:
mmc
Message:

Fixed the Rappture::encoding::is function to properly detect embedded
nulls within a string and classify the string as "binary".

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/RpEncode.cc

    r675 r725  
    3333isbinary(const char* buf, int size)
    3434{
    35     int index = 0;
    36 
    37     if (size == -1) {
     35    if (size < 0) {
    3836        size = strlen(buf);
    3937    }
    4038
    41     for (index = 0; index < size; index++) {
    42         if (((buf[index] >= '\000') && (buf[index] <= '\010')) ||
    43             ((buf[index] >= '\013') && (buf[index] <= '\014')) ||
    44             ((buf[index] >= '\016') && (buf[index] <= '\037')) ||
    45             ((buf[index] >= '\177') && (buf[index] <= '\377')) ) {
     39    for (int index = 0; index < size; index++) {
     40        int c = *buf++;
     41        if (((c >= '\000') && (c <= '\010')) ||
     42            ((c >= '\013') && (c <= '\014')) ||
     43            ((c >= '\016') && (c <= '\037')) ||
     44            ((c >= '\177') && (c <= '\377')) ) {
    4645            // data is binary
    4746            return index+1;
    4847        }
    49 
    5048    }
    5149    return 0;
Note: See TracChangeset for help on using the changeset viewer.