Changeset d222c44


Ignore:
Timestamp:
Jan 2, 2011, 3:35:15 PM (14 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
719119de
Parents:
2bc6ad35
git-author:
David Benjamin <davidben@mit.edu> (12/14/10 23:53:38)
git-committer:
David Benjamin <davidben@mit.edu> (01/02/11 15:35:15)
Message:
Kill owl_getquoting and fix quoting bugs

That function is nonsense. Fix a number of quoting bugs relating to its
use (and lack thereof).

Also quote regex characters in CC narrows.
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • filterelement.c

    ra1d98e4 rd222c44  
    139139static void owl_filterelement_print_re(const owl_filterelement *fe, GString *buf)
    140140{
    141   const char *re, *q;
     141  const char *re;
    142142  g_string_append(buf, fe->field);
    143143  g_string_append(buf, " ");
    144144
    145145  re = owl_regex_get_string(&(fe->re));
    146   q = owl_getquoting(re);
    147   g_string_append(buf, q);
    148   g_string_append(buf, re);
    149   g_string_append(buf, q);
     146  owl_string_append_quoted_arg(buf, re);
    150147}
    151148
     
    153150{
    154151  g_string_append(buf, "filter ");
    155   g_string_append(buf, fe->field);
     152  owl_string_append_quoted_arg(buf, fe->field);
    156153}
    157154
     
    159156{
    160157  g_string_append(buf, "perl ");
    161   g_string_append(buf, fe->field);
     158  owl_string_append_quoted_arg(buf, fe->field);
    162159}
    163160
  • functions.c

    r1279f21 rd222c44  
    16321632
    16331633  owl_function_popless_text(str->str);
    1634   g_string_free(str, TRUE);
     1634  g_string_free(str, true);
    16351635}
    16361636
     
    24922492static char *owl_function_smartfilter_cc(const owl_message *m) {
    24932493  const char *ccs;
     2494  char *ccs_quoted;
    24942495  char *filtname;
    2495   char *text;
    24962496  owl_filter *f;
     2497  GString *buf;
    24972498
    24982499  ccs = owl_message_get_attribute_value(m, "zephyr_ccs");
     
    25052506  }
    25062507
    2507   text = owl_sprintf("type ^zephyr$ and filter personal and "
    2508                      "zephyr_ccs ^%s%s%s$",
    2509                      owl_getquoting(ccs), ccs, owl_getquoting(ccs));
    2510 
    2511   f = owl_filter_new_fromstring(filtname, text);
     2508  buf = g_string_new("type ^zephyr$ and filter personal and "
     2509                     "zephyr_ccs ^");
     2510  ccs_quoted = owl_text_quote(ccs, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
     2511  owl_string_append_quoted_arg(buf, ccs_quoted);
     2512  g_string_append_c(buf, '$');
     2513  owl_free(ccs_quoted);
     2514
     2515  f = owl_filter_new_fromstring(filtname, buf->str);
     2516  g_string_free(buf, true);
    25122517
    25132518  owl_global_add_filter(&g, f);
    2514 
    2515   owl_free(text);
    25162519
    25172520  return filtname;
     
    26112614  const owl_view *v;
    26122615  const owl_message *m;
    2613   const char *cmdprefix, *mclass, *minst;
    2614   char *cmd;
     2616  const char *mclass, *minst;
     2617  GString *buf;
    26152618 
    26162619  v=owl_global_get_current_view(&g);
     
    26382641                         mclass, minst);
    26392642  } else {
    2640     cmdprefix = "start-command zpunt ";
    2641     cmd = owl_malloc(strlen(cmdprefix)+strlen(mclass)+strlen(minst)+10);
    2642     strcpy(cmd, cmdprefix);
    2643     strcat(cmd, owl_getquoting(mclass));
    2644     strcat(cmd, mclass);
    2645     strcat(cmd, owl_getquoting(mclass));
     2643    buf = g_string_new("start-command zpunt ");
     2644    owl_string_append_quoted_arg(buf, mclass);
    26462645    if (type) {
    2647       strcat(cmd, " ");
    2648       strcat(cmd, owl_getquoting(minst));
    2649       strcat(cmd, minst);
    2650       strcat(cmd, owl_getquoting(minst));
     2646      g_string_append_c(buf, ' ');
     2647      owl_string_append_quoted_arg(buf, minst);
    26512648    } else {
    2652       strcat(cmd, " *");
    2653     }
    2654     owl_function_command(cmd);
    2655     owl_free(cmd);
     2649      g_string_append(buf, " *");
     2650    }
     2651    owl_function_command(buf->str);
     2652    g_string_free(buf, true);
    26562653  }
    26572654}
  • global.c

    r8510d5b rd222c44  
    710710{
    711711  char *sn_escaped;
    712   const char *quote;
    713712  g->aim_loggedin=1;
    714713  if (g->aim_screenname) owl_free(g->aim_screenname);
     
    716715  g->aim_screenname=owl_strdup(screenname);
    717716  sn_escaped = owl_text_quote(screenname, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    718   quote = owl_getquoting(sn_escaped);
    719   g->aim_screenname_for_filters=owl_sprintf("%s%s%s", quote, sn_escaped, quote);
     717  g->aim_screenname_for_filters = owl_arg_quote(sn_escaped);
    720718  owl_free(sn_escaped);
    721719}
  • text.c

    r72ec874 rd222c44  
    262262  }
    263263  return(1);
    264 }
    265 
    266 const char *owl_getquoting(const char *line)
    267 {
    268   if (line[0]=='\0') return("'");
    269   if (strchr(line, '\'')) return("\"");
    270   if (strchr(line, '"')) return("'");
    271   if (strcspn(line, "\n\t ") != strlen(line)) return("'");
    272   return("");
    273264}
    274265
Note: See TracChangeset for help on using the changeset viewer.