75 |
|
query = content; |
76 |
|
} |
77 |
|
|
78 |
– |
// api::Cout << query << ios::NewLine; |
79 |
– |
|
78 |
|
ext::Vector<ext::String> pairs(query.Split('&')); |
79 |
|
|
80 |
|
_foreach (ext::Vector<ext::String>, pair, pairs) |
82 |
|
ext::String::ConstIterator equal(pair->FindFirst('=')); |
83 |
|
ext::String name(pair->Begin(), equal), value(equal != pair->End() ? equal + 1 : equal, pair->End()); |
84 |
|
|
85 |
< |
// XXX: clean up %20, etc. |
85 |
> |
cgi.insert(std::pair<std::string, std::string>(decode(name), decode(value))); |
86 |
> |
} |
87 |
> |
} |
88 |
> |
|
89 |
> |
std::string Represent::decode(const ext::String& encoded) |
90 |
> |
{ |
91 |
> |
std::string decoded(encoded); |
92 |
> |
std::string::size_type pos(0); |
93 |
|
|
94 |
< |
cgi.insert(std::pair<std::string, std::string>(name, value)); |
94 |
> |
while ((pos = decoded.find_first_of("%+", pos)) != std::string::npos) switch (decoded[pos]) |
95 |
> |
{ |
96 |
> |
case '%': |
97 |
> |
decoded.replace(pos, 3, 1, Hexadecimal(decoded.substr(pos + 1, 2), false).convert<char>(false)); |
98 |
> |
break; |
99 |
> |
case '+': |
100 |
> |
decoded[pos] = ' '; |
101 |
|
} |
102 |
+ |
|
103 |
+ |
return decoded; |
104 |
|
} |
105 |
|
|
106 |
|
void Represent::headings(xml::TextWriter& xhtml) |
186 |
|
MultiMapConstIterator type(cgi.lower_bound("type")), type_(cgi.upper_bound("type")), data(cgi.lower_bound("data")), data_(cgi.upper_bound("data")), input(cgi.lower_bound("input")), input_(cgi.upper_bound("input")); |
187 |
|
ext::Vector<Item> items; |
188 |
|
|
189 |
< |
_foru (index, 0, *count.begin()) |
189 |
> |
_foru (index, 0, *count.begin() < 128 ? *count.begin() : 128) |
190 |
|
{ |
191 |
|
Item item(DataType(type != type_ ? type->second : std::string()), data != data_ ? data->second : std::string(), InputType(input != input_ ? input->second : std::string())); |
192 |
|
|
199 |
|
|
200 |
|
_rfor (MultiMapConstIterator, delete_, cgi.lower_bound("delete"), cgi.upper_bound("delete")) items.RemoveAt(lexical_cast<size_t>(delete_->second)); |
201 |
|
|
202 |
+ |
if (!items.IsEmpty() && items.First().data.IsEmpty()) items.RemoveFirst(); |
203 |
+ |
|
204 |
|
size_t index(0); |
205 |
|
|
206 |
|
_foreach (ext::Vector<Item>, item, items) switch (item->type) |
355 |
|
case InputType::INPUT_Binary: |
356 |
|
return Binary(item.data, false).convert<char>(false); |
357 |
|
case InputType::INPUT_Hexadecimal: |
358 |
< |
return Hexadecimal(input.data, false).convert<char>(false); |
358 |
> |
return Hexadecimal(item.data, false).convert<char>(false); |
359 |
|
} |
360 |
|
} |
361 |
|
|
379 |
|
xhtml.OutputText(lexical_cast<ext::String>(type)); |
380 |
|
} |
381 |
|
|
382 |
+ |
// XXX: damn, this one is really quite screwy |
383 |
|
template <> |
384 |
|
void Represent::normal(xml::TextWriter& xhtml, const char& char_) |
385 |
|
{ |
386 |
< |
xhtml.OutputText(ext::CodePoint(char_)); |
386 |
> |
xhtml.OutputText("'"); |
387 |
> |
xhtml.OutputText(std::string(1, char_).c_str()); |
388 |
> |
xhtml.OutputText("'"); |
389 |
|
} |
390 |
|
|
391 |
|
template <> |
392 |
|
void Represent::normal(xml::TextWriter& xhtml, const std::string& string) |
393 |
|
{ |
394 |
+ |
xhtml.OutputText("\""); |
395 |
|
xhtml.OutputText(string); |
396 |
+ |
xhtml.OutputText("\""); |
397 |
|
} |
398 |
|
|
399 |
|
template <> |
400 |
|
void Represent::normal(xml::TextWriter& xhtml, const ext::String& string) |
401 |
|
{ |
402 |
+ |
xhtml.OutputText("\""); |
403 |
|
xhtml.OutputText(string); |
404 |
+ |
xhtml.OutputText("\""); |
405 |
|
} |
406 |
|
|
407 |
|
template <typename Type> |
422 |
|
xml::ScopeElement(xhtml, "br"); |
423 |
|
|
424 |
|
xhtml.OutputText(Binary(*atom)); |
425 |
+ |
xhtml.OutputText(" = '"); |
426 |
+ |
xhtml.OutputText(ext::CodePoint(*atom)); |
427 |
+ |
xhtml.OutputText("'"); |
428 |
|
} |
429 |
|
} |
430 |
|
|
440 |
|
xml::ScopeElement(xhtml, "br"); |
441 |
|
|
442 |
|
xhtml.OutputText(Binary(*atom)); |
443 |
+ |
xhtml.OutputText(" = '"); |
444 |
+ |
xhtml.OutputText(ext::CodePoint(*atom)); |
445 |
+ |
xhtml.OutputText("'"); |
446 |
|
} |
447 |
|
} |
448 |
|
|
463 |
|
{ |
464 |
|
xml::ScopeElement(xhtml, "br"); |
465 |
|
|
466 |
< |
xhtml.OutputText(Hexadecimal(string)); |
466 |
> |
xhtml.OutputText(Hexadecimal(*atom)); |
467 |
> |
xhtml.OutputText(" = '"); |
468 |
> |
xhtml.OutputText(ext::CodePoint(*atom)); |
469 |
> |
xhtml.OutputText("'"); |
470 |
|
} |
471 |
|
} |
472 |
|
|
481 |
|
{ |
482 |
|
xml::ScopeElement(xhtml, "br"); |
483 |
|
|
484 |
< |
xhtml.OutputText(Hexadecimal(string)); |
484 |
> |
xhtml.OutputText(Hexadecimal(*atom)); |
485 |
> |
xhtml.OutputText(" = '"); |
486 |
> |
xhtml.OutputText(ext::CodePoint(*atom)); |
487 |
> |
xhtml.OutputText("'"); |
488 |
|
} |
489 |
|
} |