PennMUSH Community

Changeset 832

Show
Ignore:
Timestamp:
05/08/07 20:44:51 (2 years ago)
Author:
shawnw
Message:

expr: #7321: Use gperf to generate the lookup function for allowed HTML tags.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 1.8.3/branches/experimental/hdrs/game.h

    r525 r832  
    1919extern void init_flagspaces(void);  /* flags.c */ 
    2020extern void init_flag_table(const char *ns);    /* flags.c */ 
    21 extern void init_tag_hashtab(void); /* funstr.c */ 
    2221extern void init_pronouns(void);    /* funstr.c */ 
    2322 
  • 1.8.3/branches/experimental/src/Makefile.in

    r821 r832  
    140140    fi 
    141141 
     142../hdrs/patches.h: 
     143    if [ ! -f ../hdrs/patches.h ]; then \ 
     144    (cd ../utils; sh mkcmds.sh patches); \ 
     145    fi 
     146 
     147../po/pennmush.pot: $(C_FILES) $(H_FILES) 
     148    xgettext -d pennmush -kT -o ../po/pennmush.pot $(C_FILES) $(H_FILES) 
     149 
     150 
     151htmltab.c: htmltab.gperf 
     152    gperf --output-file htmltab.c htmltab.gperf 
    142153 
    143154etags:  
     
    11891200markup.o: ../hdrs/log.h 
    11901201markup.o: ../hdrs/game.h 
     1202markup.o: htmltab.c 
    11911203match.o: ../hdrs/copyrite.h 
    11921204match.o: ../config.h 
  • 1.8.3/branches/experimental/src/game.c

    r815 r832  
    727727  init_func_hashtab(); 
    728728  init_math_hashtab(); 
    729   init_tag_hashtab(); 
    730729  init_ansi_codes(); 
    731730  init_aname_table(); 
     
    23252324extern HASHTAB htab_user_function; 
    23262325extern HASHTAB htab_math; 
    2327 extern HASHTAB htab_tag; 
    23282326extern HASHTAB htab_player_list; 
    23292327extern HASHTAB htab_reserved_aliases; 
     
    23482346  hash_stats(player, &htab_user_function, "@Functions"); 
    23492347  hash_stats(player, &htab_math, "Math funs"); 
    2350   hash_stats(player, &htab_tag, "HTML tags"); 
    23512348  hash_stats(player, &htab_player_list, "Players"); 
    23522349  hash_stats(player, &htab_reserved_aliases, "Aliases"); 
  • 1.8.3/branches/experimental/src/markup.c

    r807 r832  
    6666/* Now the code */ 
    6767 
    68 HASHTAB htab_tag;  /**< Hash table of safe html tags */ 
    69  
    7068static int write_ansi_close(char *buff, char **bp); 
    7169static int is_ansi_oldstyle(const char *str); 
     
    7674 compare_starts(const void *a, const void *b); 
    7775 
     76/* Functions in htmltab.c (Generated by gperf) */ 
     77static unsigned int htmltag_hash(const char *s, unsigned int len); 
     78static const char *is_allowed_tag(const char *tag, unsigned int len); 
    7879 
    7980/* ARGSUSED */ 
     
    178179{ 
    179180  int i; 
    180   if (!Wizard(executor) && !hash_find(&htab_tag, strupper(args[0]))) { 
     181  if (!Wizard(executor) 
     182      && !is_allowed_tag(args[0], arglens[0])) { 
    181183    safe_str("#-1", buff, bp); 
    182184    return; 
     
    197199FUNCTION(fun_endtag) 
    198200{ 
    199   if (!Wizard(executor) && !hash_find(&htab_tag, strupper(args[0]))) 
     201  if (!Wizard(executor) && !is_allowed_tag(args[0], arglens[0])) 
    200202    safe_str("#-1", buff, bp); 
    201203  else 
     
    206208FUNCTION(fun_tagwrap) 
    207209{ 
    208   if (!Wizard(executor) && !hash_find(&htab_tag, strupper(args[0]))) 
     210  if (!Wizard(executor) && !is_allowed_tag(args[0], arglens[0])) 
    209211    safe_str("#-1", buff, bp); 
    210212  else { 
     
    20882090} 
    20892091 
    2090 /** Initialize the html tag hash table with all the safe tags from HTML 4.0 */ 
    2091 void 
    2092 init_tag_hashtab(void) 
    2093 
    2094   static char dummy = 1; 
    2095   int i = 0; 
    2096   static const char *safetags[] = { "A", "B", "I", "U", "STRONG", "EM", 
    2097     "ADDRESS", "BLOCKQUOTE", "CENTER", "DEL", "DIV", 
    2098     "H1", "H2", "H3", "H4", "H5", "H6", "HR", "INS", 
    2099     "P", "PRE", "DIR", "DL", "DT", "DD", "LI", "MENU", "OL", "UL", 
    2100     "TABLE", "CAPTION", "COLGROUP", "COL", "THEAD", "TFOOT", 
    2101     "TBODY", "TR", "TD", "TH", 
    2102     "BR", "FONT", "IMG", "SPAN", "SUB", "SUP", 
    2103     "ABBR", "ACRONYM", "CITE", "CODE", "DFN", "KBD", "SAMP", "VAR", 
    2104     "BIG", "S", "SMALL", "STRIKE", "TT", 
    2105     NULL 
    2106   }; 
    2107   hashinit(&htab_tag, 64, 1); 
    2108   while (safetags[i]) { 
    2109     hashadd(safetags[i], (void *) &dummy, &htab_tag); 
    2110     i++; 
    2111   } 
    2112 
     2092/* File generated by gperf */ 
     2093#include "htmltab.c"