diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-11-14 15:02:58 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-11-14 18:13:08 +0100 |
commit | 0666bc342b391dbb80dfa4c8812c010bdc00afc0 (patch) | |
tree | 5b8c685f4c40f4ce2a166e61f08aea45a75e8e06 /source/pdf | |
parent | ecba03d23babb5c8e50ae1a02cf549fa6b0cef63 (diff) | |
download | mupdf-0666bc342b391dbb80dfa4c8812c010bdc00afc0.tar.xz |
pdf: Use URI dictionary for relative URIs.
Diffstat (limited to 'source/pdf')
-rw-r--r-- | source/pdf/pdf-annot.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c index ec19f27a..b500d12f 100644 --- a/source/pdf/pdf-annot.c +++ b/source/pdf/pdf-annot.c @@ -179,7 +179,18 @@ pdf_parse_link_action(fz_context *ctx, pdf_document *doc, pdf_obj *action) } else if (pdf_name_eq(ctx, PDF_NAME_URI, obj)) { - return pdf_to_utf8(ctx, pdf_dict_get(ctx, action, PDF_NAME_URI)); + /* URI entries are ASCII strings */ + const char *uri = pdf_to_str_buf(ctx, pdf_dict_get(ctx, action, PDF_NAME_URI)); + if (!fz_is_external_link(ctx, uri)) + { + pdf_obj *uri_base_obj = pdf_dict_getp(ctx, pdf_trailer(ctx, doc), "Root/URI/Base"); + const char *uri_base = uri_base_obj ? pdf_to_str_buf(ctx, uri_base_obj) : "file://"; + char *new_uri = fz_malloc(ctx, strlen(uri_base) + strlen(uri) + 1); + strcpy(new_uri, uri_base); + strcat(new_uri, uri); + return new_uri; + } + return fz_strdup(ctx, uri); } else if (pdf_name_eq(ctx, PDF_NAME_Launch, obj)) { @@ -205,6 +216,10 @@ pdf_load_link(fz_context *ctx, pdf_document *doc, pdf_obj *dict, const fz_matrix char *uri; fz_link *link; + obj = pdf_dict_get(ctx, dict, PDF_NAME_Subtype); + if (!pdf_name_eq(ctx, obj, PDF_NAME_Link)) + return NULL; + obj = pdf_dict_get(ctx, dict, PDF_NAME_Rect); if (!obj) return NULL; |