aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llxml/llxmlnode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llxml/llxmlnode.cpp')
-rw-r--r--linden/indra/llxml/llxmlnode.cpp107
1 files changed, 46 insertions, 61 deletions
diff --git a/linden/indra/llxml/llxmlnode.cpp b/linden/indra/llxml/llxmlnode.cpp
index 275b6c2..757e2f7 100644
--- a/linden/indra/llxml/llxmlnode.cpp
+++ b/linden/indra/llxml/llxmlnode.cpp
@@ -3024,80 +3024,65 @@ LLXMLNodePtr LLXMLNode::getNextSibling()
3024LLString LLXMLNode::getTextContents() const 3024LLString LLXMLNode::getTextContents() const
3025{ 3025{
3026 std::string msg; 3026 std::string msg;
3027 LLXMLNodeList p_children; 3027 LLString contents = mValue;
3028 getChildren("p", p_children); 3028 std::string::size_type n = contents.find_first_not_of(" \t\n");
3029 if (p_children.size() > 0) 3029 if (n != std::string::npos && contents[n] == '\"')
3030 { 3030 {
3031 // Case 1: node has <p>text</p> tags 3031 // Case 1: node has quoted text
3032 LLXMLNodeList::iterator itor; 3032 S32 num_lines = 0;
3033 for (itor = p_children.begin(); itor != p_children.end(); ++itor) 3033 while(1)
3034 { 3034 {
3035 LLXMLNodePtr p = itor->second; 3035 // mContents[n] == '"'
3036 msg += p->getValue() + "\n"; 3036 ++n;
3037 } 3037 std::string::size_type t = n;
3038 } 3038 std::string::size_type m = 0;
3039 else 3039 // fix-up escaped characters
3040 {
3041 LLString contents = mValue;
3042 std::string::size_type n = contents.find_first_not_of(" \t\n");
3043 if (n != std::string::npos && contents[n] == '\"')
3044 {
3045 // Case 2: node has quoted text
3046 S32 num_lines = 0;
3047 while(1) 3040 while(1)
3048 { 3041 {
3049 // mContents[n] == '"' 3042 m = contents.find_first_of("\\\"", t); // find first \ or "
3050 ++n; 3043 if ((m == std::string::npos) || (contents[m] == '\"'))
3051 std::string::size_type t = n;
3052 std::string::size_type m = 0;
3053 // fix-up escaped characters
3054 while(1)
3055 {
3056 m = contents.find_first_of("\\\"", t); // find first \ or "
3057 if ((m == std::string::npos) || (contents[m] == '\"'))
3058 {
3059 break;
3060 }
3061 contents.erase(m,1);
3062 t = m+1;
3063 }
3064 if (m == std::string::npos)
3065 { 3044 {
3066 break; 3045 break;
3067 } 3046 }
3068 // mContents[m] == '"' 3047 contents.erase(m,1);
3069 num_lines++; 3048 t = m+1;
3070 msg += contents.substr(n,m-n) + "\n"; 3049 }
3071 n = contents.find_first_of("\"", m+1); 3050 if (m == std::string::npos)
3072 if (n == std::string::npos) 3051 {
3052 break;
3053 }
3054 // mContents[m] == '"'
3055 num_lines++;
3056 msg += contents.substr(n,m-n) + "\n";
3057 n = contents.find_first_of("\"", m+1);
3058 if (n == std::string::npos)
3059 {
3060 if (num_lines == 1)
3073 { 3061 {
3074 if (num_lines == 1) 3062 msg.erase(msg.size()-1); // remove "\n" if only one line
3075 {
3076 msg.erase(msg.size()-1); // remove "\n" if only one line
3077 }
3078 break;
3079 } 3063 }
3064 break;
3080 } 3065 }
3081 } 3066 }
3082 else 3067 }
3068 else
3069 {
3070 // Case 2: node has embedded text (beginning and trailing whitespace trimmed)
3071 LLString::size_type start = mValue.find_first_not_of(" \t\n");
3072 if (start != mValue.npos)
3083 { 3073 {
3084 // Case 3: node has embedded text (beginning and trailing whitespace trimmed) 3074 LLString::size_type end = mValue.find_last_not_of(" \t\n");
3085 LLString::size_type start = mValue.find_first_not_of(" \t\n"); 3075 if (end != mValue.npos)
3086 if (start != mValue.npos)
3087 { 3076 {
3088 LLString::size_type end = mValue.find_last_not_of(" \t\n"); 3077 msg = mValue.substr(start, end+1-start);
3089 if (end != mValue.npos) 3078 }
3090 { 3079 else
3091 msg = mValue.substr(start, end+1-start); 3080 {
3092 } 3081 msg = mValue.substr(start);
3093 else
3094 {
3095 msg = mValue.substr(start);
3096 }
3097 } 3082 }
3098 // Convert any internal CR to LF
3099 msg = utf8str_removeCRLF(msg);
3100 } 3083 }
3084 // Convert any internal CR to LF
3085 msg = utf8str_removeCRLF(msg);
3101 } 3086 }
3102 return msg; 3087 return msg;
3103} 3088}