MCPcopy Create free account
hub / github.com/cuberite/cuberite / ParseFormUrlEncoded

Method ParseFormUrlEncoded

src/HTTPServer/HTTPFormParser.cpp:152–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150
151
152void cHTTPFormParser::ParseFormUrlEncoded(void)
153{
154 // Parse m_IncomingData for all the variables; no more data is incoming, since this is called from Finish()
155 // This may not be the most performant version, but we don't care, the form data is small enough and we're not a full-fledged web server anyway
156 AStringVector Lines = StringSplit(m_IncomingData, "&");
157 for (AStringVector::iterator itr = Lines.begin(), end = Lines.end(); itr != end; ++itr)
158 {
159 AStringVector Components = StringSplit(*itr, "=");
160 switch (Components.size())
161 {
162 default:
163 {
164 // Neither name nor value, or too many "="s, mark this as invalid form:
165 m_IsValid = false;
166 return;
167 }
168 case 1:
169 {
170 // Only name present
171 (*this)[URLDecode(ReplaceAllCharOccurrences(Components[0], '+', ' '))] = "";
172 break;
173 }
174 case 2:
175 {
176 // name=value format:
177 (*this)[URLDecode(ReplaceAllCharOccurrences(Components[0], '+', ' '))] = URLDecode(ReplaceAllCharOccurrences(Components[1], '+', ' '));
178 break;
179 }
180 }
181 } // for itr - Lines[]
182 m_IncomingData.clear();
183}
184
185
186

Callers

nothing calls this directly

Calls 7

StringSplitFunction · 0.85
URLDecodeFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
sizeMethod · 0.80
clearMethod · 0.80

Tested by

no test coverage detected