aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/apache/request.cxx32
-rw-r--r--web/apache/service.cxx2
-rw-r--r--web/module8
-rw-r--r--web/xhtml25
4 files changed, 38 insertions, 29 deletions
diff --git a/web/apache/request.cxx b/web/apache/request.cxx
index 497d2d6..9887104 100644
--- a/web/apache/request.cxx
+++ b/web/apache/request.cxx
@@ -99,33 +99,31 @@ namespace web
{
if (::strcasecmp (h->key, "Cookie") == 0)
{
- for (const char* n (h->val); n != 0; )
+ for (const char* n (h->val); n != nullptr; )
{
const char* v (strchr (n, '='));
const char* e (strchr (n, ';'));
- if (e && e < v)
- v = 0;
+ if (e != nullptr && e < v)
+ v = nullptr;
- string name (v
+ string name (v != nullptr
? mime_url_decode (n, v, true)
: (e
? mime_url_decode (n, e, true)
: mime_url_decode (n, n + strlen (n), true)));
- string value;
+ optional<string> value;
if (v++)
- {
value = e
? mime_url_decode (v, e, true)
: mime_url_decode (v, v + strlen (v), true);
- }
- if (!name.empty () || !value.empty ())
+ if (!name.empty () || value)
cookies_->emplace_back (move (name), move (value));
- n = e ? e + 1 : 0;
+ n = e ? e + 1 : nullptr;
}
}
}
@@ -252,33 +250,31 @@ namespace web
void request::
parse_parameters (const char* args)
{
- for (auto n (args); n != 0; )
+ for (auto n (args); n != nullptr; )
{
const char* v (strchr (n, '='));
const char* e (strchr (n, '&'));
- if (e && e < v)
- v = 0;
+ if (e != nullptr && e < v)
+ v = nullptr;
- string name (v
+ string name (v != nullptr
? mime_url_decode (n, v) :
(e
? mime_url_decode (n, e)
: mime_url_decode (n, n + strlen (n))));
- string value;
+ optional<string> value;
if (v++)
- {
value = e
? mime_url_decode (v, e)
: mime_url_decode (v, v + strlen (v));
- }
- if (!name.empty () || !value.empty ())
+ if (!name.empty () || value)
parameters_->emplace_back (move (name), move (value));
- n = e ? e + 1 : 0;
+ n = e ? e + 1 : nullptr;
}
}
}
diff --git a/web/apache/service.cxx b/web/apache/service.cxx
index 69bb874..782e09b 100644
--- a/web/apache/service.cxx
+++ b/web/apache/service.cxx
@@ -70,7 +70,7 @@ namespace web
return 0;
}
- srv.options_.emplace_back (name, value);
+ srv.options_.emplace_back (name, string (value));
return 0;
}
diff --git a/web/module b/web/module
index 7398d45..25c4bf2 100644
--- a/web/module
+++ b/web/module
@@ -14,6 +14,7 @@
#include <stdexcept> // runtime_error
#include <butl/path>
+#include <butl/optional>
namespace web
{
@@ -57,15 +58,18 @@ namespace web
sequence_error (std::string d): std::runtime_error (std::move (d)) {}
};
+ template <typename T>
+ using optional = butl::optional<T>;
+
struct name_value
{
// These should eventually become string_view's.
//
std::string name;
- std::string value;
+ optional<std::string> value;
name_value () {}
- name_value (std::string n, std::string v)
+ name_value (std::string n, optional<std::string> v)
: name (std::move (n)), value (std::move (v)) {}
};
diff --git a/web/xhtml b/web/xhtml
index b4c1a0d..7446a27 100644
--- a/web/xhtml
+++ b/web/xhtml
@@ -309,10 +309,16 @@ namespace web
static const element H5 ("h5");
static const element H6 ("h6");
static const element LI ("li");
+ static const element LINK ("link");
static const element META ("meta");
static const element P ("p");
static const element PRE ("pre");
+ static const element TABLE ("table");
+ static const element TBODY ("tbody");
+ static const element TD ("td");
+ static const element TH ("th");
static const element TITLE ("title");
+ static const element TR ("tr");
static const element UL ("ul");
static const inline_element A ("a");
@@ -326,14 +332,17 @@ namespace web
// Attributes.
//
- static const attribute CLASS ("class");
- static const attribute CONTENT ("content");
- static const attribute HREF ("href");
- static const attribute ID ("id");
- static const attribute NAME ("name");
- static const attribute STYLE ("style");
- static const attribute TYPE ("type");
- static const attribute VALUE ("value");
+
+ static const attribute AUTOFOCUS ("autofocus");
+ static const attribute CLASS ("class");
+ static const attribute CONTENT ("content");
+ static const attribute HREF ("href");
+ static const attribute ID ("id");
+ static const attribute NAME ("name");
+ static const attribute REL ("rel");
+ static const attribute STYLE ("style");
+ static const attribute TYPE ("type");
+ static const attribute VALUE ("value");
}
}