| 35 | bool TiXmlBase::condenseWhiteSpace = true; |
| 36 | |
| 37 | void TiXmlBase::PutString(const TIXML_STRING& str, TIXML_STRING* outString) |
| 38 | { |
| 39 | int i = 0; |
| 40 | |
| 41 | while (i < (int)str.length()) |
| 42 | { |
| 43 | unsigned char c = (unsigned char)str[i]; |
| 44 | |
| 45 | if (c == '&' && i < ((int)str.length() - 2) && str[i + 1] == '#' && str[i + 2] == 'x') |
| 46 | { |
| 47 | // Hexadecimal character reference. |
| 48 | // Pass through unchanged. |
| 49 | // © -- copyright symbol, for example. |
| 50 | // |
| 51 | // The -1 is a bug fix from Rob Laveaux. It keeps |
| 52 | // an overflow from happening if there is no ';'. |
| 53 | // There are actually 2 ways to exit this loop - |
| 54 | // while fails (error case) and break (semicolon found). |
| 55 | // However, there is no mechanism (currently) for |
| 56 | // this function to return an error. |
| 57 | while (i < (int)str.length() - 1) |
| 58 | { |
| 59 | outString->append(str.c_str() + i, 1); |
| 60 | ++i; |
| 61 | if (str[i] == ';') |
| 62 | break; |
| 63 | } |
| 64 | } |
| 65 | else if (c == '&') |
| 66 | { |
| 67 | outString->append(entity[0].str, entity[0].strLength); |
| 68 | ++i; |
| 69 | } |
| 70 | else if (c == '<') |
| 71 | { |
| 72 | outString->append(entity[1].str, entity[1].strLength); |
| 73 | ++i; |
| 74 | } |
| 75 | else if (c == '>') |
| 76 | { |
| 77 | outString->append(entity[2].str, entity[2].strLength); |
| 78 | ++i; |
| 79 | } |
| 80 | else if (c == '\"') |
| 81 | { |
| 82 | outString->append(entity[3].str, entity[3].strLength); |
| 83 | ++i; |
| 84 | } |
| 85 | else if (c == '\'') |
| 86 | { |
| 87 | outString->append(entity[4].str, entity[4].strLength); |
| 88 | ++i; |
| 89 | } |
| 90 | else if (c < 32) |
| 91 | { |
| 92 | // Easy pass at non-alpha/numeric/symbol |
| 93 | // Below 32 is symbolic. |
| 94 | char buf[32]; |