diff options
author | Paul Gardiner <paul@glidos.net> | 2012-07-18 14:46:04 +0100 |
---|---|---|
committer | Paul Gardiner <paul@glidos.net> | 2012-07-18 16:42:05 +0100 |
commit | 582b1679c454c84df61ab9f80df68c7985cee0fd (patch) | |
tree | a550401c7f389d279e7ee218b67b5538471b4305 | |
parent | 7eb8e51b6b889fa14aae39d282675b838aa43dc9 (diff) | |
download | mupdf-582b1679c454c84df61ab9f80df68c7985cee0fd.tar.xz |
Forms: convert strings from pdf to utf8 before passing to the js engine
-rw-r--r-- | pdf/pdf_form.c | 2 | ||||
-rw-r--r-- | pdf/pdf_js.c | 16 |
2 files changed, 7 insertions, 11 deletions
diff --git a/pdf/pdf_form.c b/pdf/pdf_form.c index ce932258..d74316fa 100644 --- a/pdf/pdf_form.c +++ b/pdf/pdf_form.c @@ -1440,7 +1440,7 @@ static void execute_action(pdf_document *doc, pdf_obj *obj, pdf_obj *a) pdf_obj *js = pdf_dict_gets(a, "JS"); if (js) { - char *code = get_string_or_stream(doc, js); + char *code = pdf_to_utf8(doc, js); fz_try(ctx) { pdf_js_setup_event(doc->js, obj); diff --git a/pdf/pdf_js.c b/pdf/pdf_js.c index 2c1029c7..e8e56c26 100644 --- a/pdf/pdf_js.c +++ b/pdf/pdf_js.c @@ -297,11 +297,11 @@ pdf_js *pdf_new_js(pdf_document *doc) fz_context *ctx = doc->ctx; pdf_js *js = NULL; pdf_obj *javascript = NULL; - fz_buffer *fzbuf = NULL; + char *codebuf = NULL; fz_var(js); fz_var(javascript); - fz_var(fzbuf); + fz_var(codebuf); fz_try(ctx) { int len, i; @@ -332,19 +332,15 @@ pdf_js *pdf_new_js(pdf_document *doc) if (pdf_is_stream(doc, pdf_to_num(code), pdf_to_gen(code))) { - unsigned char *buf; - int len; - fz_try(ctx) { - fzbuf = pdf_load_stream(doc, pdf_to_num(code), pdf_to_gen(code)); - len = fz_buffer_storage(ctx, fzbuf, &buf); - pdf_jsimp_execute_count(js->imp, (char *)buf, len); + codebuf = pdf_to_utf8(doc, code); + pdf_jsimp_execute(js->imp, codebuf); } fz_always(ctx) { - fz_drop_buffer(ctx, fzbuf); - fzbuf = NULL; + fz_free(ctx, codebuf); + codebuf = NULL; } fz_catch(ctx) { |