Changeset 1413 for trunk


Ignore:
Timestamp:
Apr 21, 2009 1:28:00 PM (15 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

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

    r1410 r1413  
    207207    bytes = buf.bytes();
    208208    if ((flags & RPENC_RAW) == 0) {
     209        unsigned int headerFlags = 0;
    209210        if ((size > 11) && (strncmp(bytes, "@@RP-ENC:z\n", 11) == 0)) {
    210211            bytes += 11;
    211212            size -= 11;
    212             flags &= ~RPENC_B64;
    213             flags |= RPENC_Z;
     213            headerFlags |= RPENC_Z;
    214214        } else if ((size > 13) && (strncmp(bytes, "@@RP-ENC:b64\n", 13) == 0)){
    215215            bytes += 13;
    216216            size -= 13;
    217             flags &= ~RPENC_Z;
    218             flags |= RPENC_B64;
     217            headerFlags |= RPENC_B64;
    219218        } else if ((size > 14) && (strncmp(bytes, "@@RP-ENC:zb64\n", 14) == 0)){
    220219            bytes += 14;
    221220            size -= 14;
    222             flags |= (RPENC_B64 | RPENC_Z);
     221            headerFlags |= (RPENC_B64 | RPENC_Z);
    223222        }
     223        if (headerFlags != 0) {
     224            unsigned int reqFlags;
     225
     226            reqFlags = flags & (RPENC_B64 | RPENC_Z);
     227            /*
     228             * If there's a header and the programmer also requested decoding
     229             * flags, verify that the two are the same.  We don't want to
     230             * penalize the programmer for over-specifying.  But we need to
     231             * catch cases when they don't match.  If you really want to
     232             * override the header, you should also specify the RPENC_RAW flag
     233             * (-noheader).
     234             */
     235            if ((reqFlags != 0) && (reqFlags != headerFlags)) {
     236                status.addError("decode flags don't match the header");
     237                return false;
     238            }
     239            flags |= headerFlags;
     240        }
    224241    }
    225242    if ((flags & (RPENC_B64 | RPENC_Z)) == 0) {
Note: See TracChangeset for help on using the changeset viewer.