Bug 696662 - Streams associated with content: URIs are not reliably read
Summary: Streams associated with content: URIs are not reliably read
Status: RESOLVED FIXED
Alias: None
Product: MuPDF
Classification: Unclassified
Component: apps (show other bugs)
Version: master
Hardware: Android Phone Android
: P4 normal
Assignee: MuPDF bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-16 14:05 UTC by Marc K.
Modified: 2016-07-19 01:58 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments
[PATCH] Poperly read streams associated with content: URIs (1.92 KB, patch)
2016-03-16 14:05 UTC, Marc K.
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc K. 2016-03-16 14:05:11 UTC
Created attachment 12393 [details]
[PATCH] Poperly read streams associated with content: URIs

E.g. attachments from K-9 Mail (recent builds) cannot be opened because InputStream.available() used MuPDFActivity.java always reports 0 for streams that have no buffered data and therefore cannot be read without blocking. The attached patch fixes the problem.
Comment 1 Robin Watts 2016-07-19 01:58:40 UTC
Fixed in:

commit 537a467dfd6392d70624805943ac65182ec881b4
Author: Robin Watts <robin.watts@artifex.com>
Date:   Mon Jul 18 12:11:45 2016 +0100

    Bug 696662: Android viewer: data from URI stream fix.

    Apparently, if MuPDF is invoked on a content stream that
    comes from a URI, then is.available() can report 0 bytes
    (as there is no data buffered). Use a modified formulation
    that reads as much data as possible from the stream into
    a BufferedOutputStream and then makes a byte array from that.

    Would be nicer if the core could actually read from the
    stream directly, perhaps, but that can wait for the new JNI
    based version.

    Thanks to Marc K for identifying the problem and supplying
    the patch.