Browse Source

case conversion including tailoring based on PyICU

async_key_management
vb 8 years ago
parent
commit
764d76afca
3 changed files with 100 additions and 2 deletions
  1. +2
    -0
      TODO.txt
  2. +16
    -1
      db/dic2csv.py
  3. +82
    -1
      src/mime.c

+ 2
- 0
TODO.txt View File

@ -1,2 +1,4 @@
- check if own key is good; if not: create a new keypair
- warning with forwarding former encrypted messages unencryptedly
- remove four-letter-words from dicts

+ 16
- 1
db/dic2csv.py View File

@ -24,8 +24,20 @@ p.add_argument('--encoding', '-e', type=str, default="utf-8",
args = p.parse_args()
try:
from icu import UnicodeString, Locale
except ImportError:
print("warning: PyICU not installed, using fallback", file=sys.stderr)
def upper(x):
return x.upper();
else:
locale = Locale(args.lang)
def upper(x):
u = UnicodeString(x)
return str(u.toUpper(locale))
_all = (
word.match(line).group(1).upper()
upper(word.match(line).group(1))
for line in FileInput(
args.hunspell + "/" + args.lang + ".dic",
openhook=hook_encoded(args.encoding)
@ -36,6 +48,9 @@ _words = [w for w in _all if len(w) > 2 and not unwanted.match(w)]
_words.sort()
_words = [w for w, g in itertools.groupby(_words)]
while len(_words) > 65536 * 2:
_words = _words[::2]
if len(_words) > 65536:
_words = _words[:65536]
elif len(_words) < 65536:


+ 82
- 1
src/mime.c View File

@ -1211,11 +1211,92 @@ static PEP_STATUS interpret_MIME(
clistiter *cur;
for (cur = clist_begin(partlist); cur; cur = clist_next(cur)) {
struct mailmime *part= clist_content(cur);
size_t index;
int r;
struct mailmime *part = clist_content(cur);
if (part == NULL)
return PEP_ILLEGAL_VALUE;
content = part->mm_content_type;
assert(content);
if (content == NULL)
return PEP_ILLEGAL_VALUE;
if (content->ct_type == NULL)
return PEP_ILLEGAL_VALUE;
switch (content->ct_type->tp_type) {
case MAILMIME_TYPE_DISCRETE_TYPE:
if (content->ct_type->tp_data.tp_discrete_type == NULL)
return PEP_ILLEGAL_VALUE;
switch (content->ct_type->tp_data.tp_discrete_type->
dt_type) {
case MAILMIME_DISCRETE_TYPE_TEXT:
if (strcmp(content->ct_subtype, "plain") ==
0) {
const char *text;
size_t length;
if (part->mm_body == NULL)
return PEP_ILLEGAL_VALUE;
text = part->mm_body->
dt_data.dt_text.dt_data;
length =
part->mm_body->dt_data.dt_text.dt_length;
index = 0;
r = mailmime_encoded_phrase_parse(
"utf-8", text, length, &index,
"utf-8", &msg->longmsg);
if (r)
return PEP_ILLEGAL_VALUE;
}
else if (strcmp(content->ct_subtype, "html") ==
0) {
const char *html;
size_t length;
if (part->mm_body == NULL)
return PEP_ILLEGAL_VALUE;
html = part->mm_body->
dt_data.dt_text.dt_data;
length =
part->mm_body->dt_data.dt_text.dt_length;
index = 0;
r = mailmime_encoded_phrase_parse(
"utf-8", html, length, &index,
"utf-8", &msg->longmsg_formatted);
if (r)
return PEP_ILLEGAL_VALUE;
}
else {
return interpret_MIME(part, msg);
}
break;
case MAILMIME_DISCRETE_TYPE_IMAGE:
case MAILMIME_DISCRETE_TYPE_AUDIO:
case MAILMIME_DISCRETE_TYPE_VIDEO:
case MAILMIME_DISCRETE_TYPE_APPLICATION:
case MAILMIME_DISCRETE_TYPE_EXTENSION:
return interpret_MIME(part, msg);
break;
default:
return PEP_ILLEGAL_VALUE;
}
break;
case MAILMIME_TYPE_COMPOSITE_TYPE:
break;
default:
return PEP_ILLEGAL_VALUE;
}
}
}
if (content->ct_type &&


Loading…
Cancel
Save