envelope: fixed&working
This commit is contained in:
		
							parent
							
								
									74e7e6226f
								
							
						
					
					
						commit
						edca5b6cc5
					
				| 
						 | 
					@ -90,18 +90,20 @@ size_t envelope_read (const std::string&data, size_t offset,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//try to parse the typeident and termident
 | 
							//try to parse the typeident and termident
 | 
				
			||||||
		std::string type, term;
 | 
							std::string type, term;
 | 
				
			||||||
		offset += begin_prefix.length();
 | 
							offset = begin + begin_prefix.length();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//find and verify possible positions of type and term strings
 | 
							//find and verify possible positions of type and term strings
 | 
				
			||||||
		size_t eoterm = data.find (begin_suffix, offset),
 | 
							size_t eoterm, eotype;
 | 
				
			||||||
		       eotype = data.find (' ', offset);
 | 
					 | 
				
			||||||
		if (eoterm == data.npos ||
 | 
					 | 
				
			||||||
		    eotype == data.npos ||
 | 
					 | 
				
			||||||
		    eotype > (eoterm - 1) )
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		type = data.substr (offset, eotype);
 | 
							eotype = data.find (' ', offset);
 | 
				
			||||||
		term = data.substr (eotype + 1, eoterm);
 | 
							if (eotype == data.npos) continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							eoterm = data.find (begin_suffix, eotype + 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (eoterm == data.npos) continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							type = data.substr (offset, eotype - offset);
 | 
				
			||||||
 | 
							term = data.substr (eotype + 1, eoterm - eotype - 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		//verify that type&term are only of acceptable characters
 | 
							//verify that type&term are only of acceptable characters
 | 
				
			||||||
		if (!acceptable_id (type) || !acceptable_id (term) )
 | 
							if (!acceptable_id (type) || !acceptable_id (term) )
 | 
				
			||||||
| 
						 | 
					@ -130,12 +132,12 @@ size_t envelope_read (const std::string&data, size_t offset,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if ( cut_pos != data.npos && cut_pos < end_pos) {
 | 
								if ( cut_pos != data.npos && cut_pos < end_pos) {
 | 
				
			||||||
				//there is cut
 | 
									//there is cut
 | 
				
			||||||
				out_parts.push_back (data.substr (offset,
 | 
									out_parts.push_back
 | 
				
			||||||
				                                  cut_pos) );
 | 
									(data.substr (offset, cut_pos - offset) );
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				//no cut, it's till the end
 | 
									//no cut, it's till the end
 | 
				
			||||||
				out_parts.push_back (data.substr (offset,
 | 
									out_parts.push_back
 | 
				
			||||||
				                                  end_pos) );
 | 
									(data.substr (offset, end_pos - offset) );
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (cut_pos == data.npos) {
 | 
								if (cut_pos == data.npos) {
 | 
				
			||||||
| 
						 | 
					@ -208,5 +210,7 @@ std::string envelope_format (const std::string&type,
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		res += end_sep;
 | 
							res += end_sep;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return res;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue