chiark / gitweb /
Get in-UI man pages working again
authorRichard Kettlewell <rjk@greenend.org.uk>
Sat, 17 May 2008 15:15:59 +0000 (16:15 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sat, 17 May 2008 15:15:59 +0000 (16:15 +0100)
.bzrignore
doc/Makefile.am
scripts/htmlman
server/actions.c

index ae0a2c9b8f2b6b3c568b2ce14d7999862c4284e4..44d44415c2f1235b3e97d629b5312faaf9b40865 100644 (file)
@@ -174,3 +174,4 @@ lib/t-words
 lib/t-wstat
 lib/t-macros
 lib/t-cgi
+doc/*.tmpl
index 0e79171ddff7b82a85455a0b06f2483a8869c006..bd2427c38fe8d9f1e7f8ca6f0c4ef7ddaf1fa2b7 100644 (file)
@@ -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
index 17e53e4ef8e39f3ea5ef9dee5c6e48a386e9fb13..17fc7f3b6a05e5da88989ad9410f5766428a675c 100755 (executable)
@@ -43,13 +43,13 @@ title=$(basename $1)
 echo "<html>"
 echo " <head>"
 if $stdhead; then
-  echo "@quiethead"
+  echo "@quiethead@#"
 fi
 echo "  <title>$title</title>"
 echo " </head>"
 echo " <body>"
 if $stdhead; then
-  echo "@stdmenu{}"
+  echo "@stdmenu{}@#"
 fi
 printf "   <pre class=manpage>"
 # this is kind of painful using only BREs
index f0b49221d22d4821fe92f0969b3fb39ee034c1c4..a504ed54647bf0045d80eb9bdab615574f8fb245 100644 (file)
@@ -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)))