From: Richard Kettlewell Date: Sat, 17 May 2008 15:15:59 +0000 (+0100) Subject: Get in-UI man pages working again X-Git-Tag: 4.0~76^2~21 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/commitdiff_plain/40dcd866894885d9d1965be248b7e04af0f853f0 Get in-UI man pages working again --- diff --git a/.bzrignore b/.bzrignore index ae0a2c9..44d4441 100644 --- a/.bzrignore +++ b/.bzrignore @@ -174,3 +174,4 @@ lib/t-words lib/t-wstat lib/t-macros lib/t-cgi +doc/*.tmpl diff --git a/doc/Makefile.am b/doc/Makefile.am index 0e79171..bd2427c 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -18,6 +18,9 @@ # USA # +noinst_DATA=$(HTMLMAN) +pkgdata_DATA=$(TMPLMAN) + SEDFILES=disorder.1 disorderd.8 disorder_config.5 \ disorder-dump.8 disorder_protocol.5 disorder-deadlock.8 \ disorder-rescan.8 disobedience.1 disorderfm.1 disorder-playrtp.1 \ @@ -34,14 +37,18 @@ man_MANS=disorderd.8 disorder.1 disorder.3 disorder_config.5 disorder-dump.8 \ noinst_MANS=tkdisorder.1 HTMLMAN=$(foreach man,$(man_MANS),$(man).html) - $(HTMLMAN) : %.html : % $(top_srcdir)/scripts/htmlman rm -f $@.new - $(top_srcdir)/scripts/htmlman -stdhead $< >$@.new + $(top_srcdir)/scripts/htmlman $< >$@.new chmod 444 $@.new mv -f $@.new $@ -pkgdata_DATA=$(HTMLMAN) +TMPLMAN=$(foreach man,$(man_MANS),$(man).tmpl) +$(TMPLMAN) : %.tmpl : % $(top_srcdir)/scripts/htmlman + rm -f $@.new + $(top_srcdir)/scripts/htmlman -stdhead $< >$@.new + chmod 444 $@.new + mv -f $@.new $@ EXTRA_DIST=disorderd.8.in disorder.1.in disorder_config.5.in \ disorder.3 disorder-dump.8.in disorder_protocol.5.in \ @@ -50,6 +57,6 @@ EXTRA_DIST=disorderd.8.in disorder.1.in disorder_config.5.in \ disorder-playrtp.1.in disorder-decode.8.in disorder-normalize.8 \ disorder-stats.8.in disorder-dbupgrade.8.in -CLEANFILES=$(SEDFILES) $(HTMLMAN) +CLEANFILES=$(SEDFILES) $(HTMLMAN) $(TMPLMAN) export GNUSED diff --git a/scripts/htmlman b/scripts/htmlman index 17e53e4..17fc7f3 100755 --- a/scripts/htmlman +++ b/scripts/htmlman @@ -43,13 +43,13 @@ title=$(basename $1) echo "" echo " " if $stdhead; then - echo "@quiethead" + echo "@quiethead@#" fi echo " $title" echo " " echo " " if $stdhead; then - echo "@stdmenu{}" + echo "@stdmenu{}@#" fi printf "
"
 # this is kind of painful using only BREs
diff --git a/server/actions.c b/server/actions.c
index f0b4922..a504ed5 100644
--- a/server/actions.c
+++ b/server/actions.c
@@ -166,6 +166,27 @@ static const struct action {
   { "remove", act_remove },
 };
 
+/** @brief Check that an action name is valid
+ * @param name Action
+ * @return 1 if valid, 0 if not
+ */
+static int dcgi_valid_action(const char *name) {
+  int c;
+
+  /* First character must be letter or digit (this also requires there to _be_
+   * a first character) */
+  if(!isalnum((unsigned char)*name))
+    return 0;
+  /* Only letters, digits, '.' and '-' allowed */
+  while((c = (unsigned char)*name++)) {
+    if(!(isalnum(c)
+         || c == '.'
+         || c == '_'))
+      return 0;
+  }
+  return 1;
+}
+
 /** @brief Expand a template
  * @param name Base name of template, or NULL to consult CGI args
  */
@@ -176,9 +197,7 @@ void dcgi_expand(const char *name) {
   if((found = mx_find("macros.tmpl")))
     mx_expand_file(found, sink_discard(), 0);
   /* For unknown actions check that they aren't evil */
-  for(p = name; *p && isalnum((unsigned char)*p); ++p)
-    ;
-  if(*p)
+  if(!dcgi_valid_action(name))
     fatal(0, "invalid action name '%s'", name);
   byte_xasprintf((char **)&p, "%s.tmpl", name);
   if(!(found = mx_find(p)))