Ignore:
Timestamp:
Jan 7, 2009 9:31:14 AM (14 years ago)
Author:
dkearney
Message:

fixing rp library's get() function for retrieving encoded data. if the data is encoded there is no need to do xml entity translation. adding a function rappture's encode class for checking to see if a string has a proper header encode header. adding corresponding tcl functions and tests. also adjusting some of the int declarations to size_t.

File:
1 edited

Legend:

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

    r1041 r1264  
    14571457        int myChildCount = 0;
    14581458
    1459         parentNode = NULL;
     1459        parentNode = NULL;
    14601460        if (path.empty()) {
    14611461            // an empty path uses the current RpLibrary as parent
     
    15391539
    15401540    inData = Rappture::Buffer(retCStr);
    1541     status &= Rappture::encoding::decode(inData,0);
    1542     status.addContext("RpLibrary::getSting");
    1543     // inData.append("\0",1);
    1544 
    1545     if (translateFlag == RPLIB_TRANSLATE) {
    1546         translatedContents = ERTranslator.decode(inData.bytes(),inData.size());
    1547         if (translatedContents == NULL) {
    1548             // translation failed
    1549             if (!status) {
    1550                 status.error("Error while translating entity references");
    1551                 status.addContext("RpLibrary::getSting");
    1552             }
    1553         }
    1554         else {
    1555             // subtract 1 from size because ERTranslator adds extra NULL
    1556             retStr = std::string(translatedContents,ERTranslator.size()-1);
    1557             translatedContents = NULL;
    1558         }
    1559     }
    1560     else {
     1541
     1542    if (Rappture::encoding::isencoded(inData.bytes(),inData.size()) != 0) {
     1543        // data is encoded,
     1544        // coming from an rplib, this means it was at least base64 encoded
     1545        // there is no reason to do entity translation
     1546        // because base64 character set does not include xml entity chars
     1547        status &= Rappture::encoding::decode(inData,0);
     1548        status.addContext("RpLibrary::getSting");
    15611549        retStr = std::string(inData.bytes(),inData.size());
     1550    } else {
     1551        // check translateFlag to see if we need to translate entity refs
     1552        if (translateFlag == RPLIB_TRANSLATE) {
     1553            translatedContents = ERTranslator.decode(inData.bytes(),inData.size());
     1554            if (translatedContents == NULL) {
     1555                // translation failed
     1556                if (!status) {
     1557                    status.error("Error while translating entity references");
     1558                    status.addContext("RpLibrary::getSting");
     1559                }
     1560            } else {
     1561                // subtract 1 from size because ERTranslator adds extra NULL
     1562                retStr = std::string(translatedContents,ERTranslator.size()-1);
     1563                translatedContents = NULL;
     1564            }
     1565        }
    15621566    }
    15631567
     
    19571961    Rappture::Buffer inData;
    19581962    unsigned int bytesWritten = 0;
    1959     int flags = 0;
     1963    size_t flags = 0;
    19601964
    19611965    if (!this->root) {
Note: See TracChangeset for help on using the changeset viewer.