githelper.git / githelper.pike

version» Context lines:

githelper.git/githelper.pike:116:   {    return (!name) || (<"utf-8", "utf8">)[lower_case(name)];   }      string check_encoding(string data, string|void encoding)   {    if(is_encoding_utf8(encoding))    encoding = "UTF-8";    mixed err = catch {    Locale.Charset.Decoder decoder = Locale.Charset.decoder(encoding); -  if(search(decoder->feed(data)->drain(), "\ufffd")>=0) +  foreach(Array.uniq(values(decoder->feed(data)->drain())), int c) +  switch(c) { +  case 0xfffd:    return "Undefinied character detected\n"; -  +  case '\t': +  case '\n': +  case '\r': /* ? */ +  /* Allowed control character */ +  break; +  default: +  if (c<32 || (c>=0x80 && c<0xa0)) +  return sprintf("Forbidden control character 0x%02x detected\n", c); +  }    };    return err && err[0];   }      string check_commit_msg(string commit)   {    string message = run_git("cat-file", "commit", commit);    string encoding = 0;    string headers = (message/"\n\n")[0];    foreach(headers/"\n", string headerline) {