| 133 | |
| 134 | |
| 135 | void HTMLForm::readQuery(ReadBuffer & in) |
| 136 | { |
| 137 | size_t fields = 0; |
| 138 | char ch = 0; // silence "uninitialized" warning from gcc-* |
| 139 | bool is_first = true; |
| 140 | |
| 141 | while (true) |
| 142 | { |
| 143 | if (max_fields_number > 0 && fields == max_fields_number) |
| 144 | throw Poco::Net::HTMLFormException("Too many form fields"); |
| 145 | |
| 146 | std::string name; |
| 147 | std::string value; |
| 148 | |
| 149 | while (in.read(ch) && ch != '=' && ch != '&') |
| 150 | { |
| 151 | if (ch == '+') |
| 152 | ch = ' '; |
| 153 | if (name.size() < max_field_name_size) |
| 154 | name += ch; |
| 155 | else |
| 156 | throw Poco::Net::HTMLFormException("Field name too long"); |
| 157 | } |
| 158 | |
| 159 | if (ch == '=') |
| 160 | { |
| 161 | while (in.read(ch) && ch != '&') |
| 162 | { |
| 163 | if (ch == '+') |
| 164 | ch = ' '; |
| 165 | if (value.size() < max_field_value_size) |
| 166 | value += ch; |
| 167 | else |
| 168 | throw Poco::Net::HTMLFormException("Field value too long"); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | // Remove UTF-8 BOM from first name, if present |
| 173 | if (is_first) |
| 174 | Poco::UTF8::removeBOM(name); |
| 175 | |
| 176 | std::string decoded_name; |
| 177 | std::string decoded_value; |
| 178 | Poco::URI::decode(name, decoded_name); |
| 179 | Poco::URI::decode(value, decoded_value); |
| 180 | add(decoded_name, decoded_value); |
| 181 | ++fields; |
| 182 | |
| 183 | is_first = false; |
| 184 | |
| 185 | if (in.eof()) |
| 186 | break; |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | |
| 191 | void HTMLForm::readMultipart(ReadBuffer & in_, PartHandler & handler) |