Changeset 719119de


Ignore:
Timestamp:
Jan 3, 2011, 8:20:52 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
c23f678
Parents:
d222c44
git-author:
David Benjamin <davidben@mit.edu> (12/15/10 00:46:46)
git-committer:
David Benjamin <davidben@mit.edu> (01/03/11 20:20:52)
Message:
Build reply commands from scratch on outgoing zwrites

We currently reuse the original zwrite line which is problematic when
the user passed -m. Instead regenerates the zwrite line from the
parsed owl_zwrite.

Repurpose the zwriteline attribute because anyone using the old
attribute probably has the same bug.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • message.c

    r72f613a r719119de  
    964964  int ret;
    965965  char hostbuff[5000];
     966  char *replyline;
    966967 
    967968  owl_message_init(m);
     
    981982  owl_message_set_opcode(m, owl_zwrite_get_opcode(z));
    982983  owl_message_set_realm(m, owl_zwrite_get_realm(z)); /* also a hack, but not here */
    983   if(z->zwriteline) {
    984     owl_message_set_zwriteline(m, z->zwriteline);
    985   }
     984
     985  /* Although not strictly the zwriteline, anyone using the unsantized version
     986   * of it probably has a bug. */
     987  replyline = owl_zwrite_get_replyline(z);
     988  owl_message_set_zwriteline(m, replyline);
     989  owl_free(replyline);
     990
    986991  owl_message_set_body(m, body);
    987992  owl_message_set_zsig(m, owl_zwrite_get_zsig(z));
  • zwrite.c

    rd4582ef r719119de  
    390390  if (z->zsig) owl_free(z->zsig);
    391391}
     392
     393/*
     394 * Returns a zwrite line suitable for replying, specifically the
     395 * message field is stripped out. Result should be freed with
     396 * owl_free.
     397 */
     398char *owl_zwrite_get_replyline(const owl_zwrite *z)
     399{
     400  /* Match ordering in zwrite help. */
     401  GString *buf = g_string_new("");
     402  int i;
     403
     404  /* Disturbingly, it is apparently possible to z->cmd to be null if
     405   * owl_zwrite_create_from_line got something starting with -. And we
     406   * can't kill it because this is exported to perl. */
     407  owl_string_append_quoted_arg(buf, z->cmd ? z->cmd : "zwrite");
     408  if (z->noping) {
     409    g_string_append(buf, " -n");
     410  }
     411  if (z->cc) {
     412    g_string_append(buf, " -C");
     413  }
     414  if (strcmp(z->class, "message")) {
     415    g_string_append(buf, " -c ");
     416    owl_string_append_quoted_arg(buf, z->class);
     417  }
     418  if (strcmp(z->inst, "personal")) {
     419    g_string_append(buf, " -i ");
     420    owl_string_append_quoted_arg(buf, z->inst);
     421  }
     422  if (z->realm && z->realm[0] != '\0') {
     423    g_string_append(buf, " -r ");
     424    owl_string_append_quoted_arg(buf, z->realm);
     425  }
     426  if (z->opcode && z->opcode[0] != '\0') {
     427    g_string_append(buf, " -O ");
     428    owl_string_append_quoted_arg(buf, z->opcode);
     429  }
     430  for (i = 0; i < owl_list_get_size(&(z->recips)); i++) {
     431    g_string_append_c(buf, ' ');
     432    owl_string_append_quoted_arg(buf, owl_list_get_element(&(z->recips), i));
     433  }
     434
     435  return g_string_free(buf, false);
     436}
Note: See TracChangeset for help on using the changeset viewer.