You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Peter Coppens <pc...@gmail.com> on 2008/11/29 13:24:33 UTC

Encryption garbles external link

Dear fop fans,

The xsl fo below renders fine to pdf and the link works when processed
without encryption options
e.g. using the command line

  fop -fo file.fo -pdf file.pdf

But with encryption options the link is garbled

  fop -noprint -nocopy  -fo  test.fo  -pdf test.pdf

When opening in Acrobat reader 8 it pops up a dialog stating

The document is trying to connect to 
file:///private/var/tmp/%1CH%3E%C2%A7%C3%AE%C2%B6%0C%C2%AAcA%C2%91%C2%8En%C2%A7y%C2%90%C3%9F%C2%AAI%C3%A3+%C2%81%C2%AA%3Euk%C3%98%05%C2%B6%C2%91


I am using fop 0.95 and jdk 1.5


Any guidance would indeed be greatly appreciated!

Peter

<?xml version="1.0" encoding="iso-8859-1"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">2
    <fo:layout-master-set>
        <fo:simple-page-master master-name="my-page">
            <fo:region-body margin="1in"/>
        </fo:simple-page-master>
    </fo:layout-master-set>
    
    <fo:page-sequence master-reference="my-page">
        <fo:flow flow-name="xsl-region-body">
            <fo:block>
                <fo:basic-link
external-destination="url('http://xmlgraphics.apache.org/')"
                    text-decoration="underline"
                    color="blue">Fop is here</fo:basic-link>
            </fo:block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

-- 
View this message in context: http://www.nabble.com/Encryption-garbles-external-link-tp20746538p20746538.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Encryption garbles external link

Posted by Andreas Delmelle <an...@telenet.be>.
On 30 Nov 2008, at 02:33, Peter Coppens wrote:

Hi Peter

> I have something that seems to be working, but I am not sure it is  
> always
> correct and I doubt it's the most optimal approach.

Thanks for the effort in investigating a fix!

>
>
> Here are the changes I did
>
> 1. PDFLink#toPDFString
> Added
>
>        this.action.setParent(this);
>
> (would be better to do this when creating the PDFUri object )

Or maybe, we should do this in PDFLink#setAction() ?

That seems to be the point where the PDFAction (PDFUri) is associated  
with the PDFLink.

I already checked whether this had unwanted side-effects when the same  
URI is used in multiple links, but that does not seem to be the case.  
The parent link is only used to get to the ancestor document, which is  
obviously the same for all links.

>
> 2. PDFUri#getAction
> <snip />
> 3. Added PDFObject#encodeText2

I'm wondering to what extent this new, separate method could be merged  
with the original encodeText(), maybe by changing the signature, and  
adding a second parameter to distinguish this case from the one  
covered by the original method.

Anyway, this is all going a bit OT for the users-list. You're welcome  
to add any progress/potential patches to the Bugzilla entry directly.  
That way, when someone finally wants to address it, he doesn't have to  
delve through the list-archives... :-)

I'll take care of adding these recent comments to the issue report.


Thanks again for your input! A fix for this seems to be much closer now.


Cheers

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Encryption garbles external link

Posted by Peter Coppens <pc...@gmail.com>.
I have something that seems to be working, but I am not sure it is always
correct and I doubt it's the most optimal approach.

Here are the changes I did

1. PDFLink#toPDFString
Added

        this.action.setParent(this);

(would be better to do this when creating the PDFUri object )

2. PDFUri#getAction

    public String getAction() {
        return "<< /URI (" + uri + ")\n/S /URI >>";
    
    }


-->

    public String getAction() {
          String uriString=new String(this.encodeText2(uri));
        
          return "<< /URI " + uriString + "\n /S /URI >>";
    
        }


3. Added PDFObject#encodeText2


    protected byte[] encodeText2(String text)  {
        if (getDocumentSafely().isEncryptionActive()) {
            final byte[] buf = PDFText.encode(text);
            byte[] enc = getDocument().getEncryption().encrypt(buf, this);
            return PDFText.toHex(enc,true).getBytes();
        
         } else {
            return encode(PDFText.escapeText(text, false));
        
         }
    
    }


Perhaps this can be used as something to start from for a patch for bug
41959 ?

Thanks,

Peter



Peter Coppens wrote:
> 
> Looks like the uri is not encrypted at all.
> 
> The code that writes out the PDFLink object seems to completely skip the
> 'normal' pdf output processing and writes out text without going through
> the encodeText method from PDFObject.
> 
> I tried to hack around a bit and after making sure PDFUri has its parent
> set to PDFLink (which it has not in the 0.95 code) something encrypted is
> written, but Acrobat still can not make sense of it. 
> 
> With the hack enabled I get 
> 
> << /Type /Annot
> /Subtype /Link
> /Rect [ 72.0 707.25 132.024 718.35 ]
> /C [ 0 0 0 ]
> /Border [ 0 0 0 ]
> /A << /URI
> (ö?§^[BÎ^OØ^^éOªûL^A;èÇ?%^Oµ?^G-?CS>^TÔñÏ?f:¯?±??!£?¯ÉÀ^]y?n¬??^OE5Ä}|
> ,^V)
> /S /URI >>
> /H /I
> 
>>>
> 
> (without the hack the URI is plain text)
> 
> 
> Unfortunately that is not what it should be...and I am clueless as to what
> is going wrong now.  I guess I will have to dive in the encryption part of
> the pdf spec to figure out what exactly needs to be encrypted for Acrobat
> to be happy with it.
> 
> Perhaps someone has suggestions on what might be wrong in the above
> Annotation object?
> 
> Thanks!
> 
> Peter
> 
> 
> 
> Peter Coppens wrote:
>> 
>> Thanks for the prompt feedback. I will try to get my head around the code
>> and see whether I can come up with a possible suggestion for a fix
>> 
>> Peter 
>> 
>> 
>> Andreas Delmelle-2 wrote:
>>> 
>>> On 29 Nov 2008, at 13:24, Peter Coppens wrote:
>>> 
>>> Hi Peter
>>> 
>>>> <snip />
>>>> But with encryption options the link is garbled
>>>>
>>>>  fop -noprint -nocopy  -fo  test.fo  -pdf test.pdf
>>>>
>>>> When opening in Acrobat reader 8 it pops up a dialog stating
>>>>
>>>> The document is trying to connect to
>>>> file:///private/var/tmp/%1CH%3E%C2%A7%C3%AE%C2%B6%0C%C2%AAcA%C2%91%C2%8En%C2%A7y%C2%90%C3%9F%C2%AAI%C3%A3+%C2%81%C2%AA%3Euk%C3%98%05%C2%B6%C2%91
>>> 
>>> Seems like this is a known bug (since 0.92) that no one has got around  
>>> to fixing yet...
>>>   (see also: http://issues.apache.org/show_bug.cgi?id=41959)
>>> 
>>> 
>>> Cheers
>>> 
>>> Andreas
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>>> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Encryption-garbles-external-link-tp20746538p20753657.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Encryption garbles external link

Posted by Peter Coppens <pc...@gmail.com>.
Looks like the uri is not encrypted at all.

The code that writes out the PDFLink object seems to completely skip the
'normal' pdf output processing and writes out text without going through the
encodeText method from PDFObject.

I tried to hack around a bit and after making sure PDFUri has its parent set
to PDFLink (which it has not in the 0.95 code) something encrypted is
written, but Acrobat still can not make sense of it. 

With the hack enabled I get 

<< /Type /Annot
/Subtype /Link
/Rect [ 72.0 707.25 132.024 718.35 ]
/C [ 0 0 0 ]
/Border [ 0 0 0 ]
/A << /URI
(ö?§^[BÎ^OØ^^éOªûL^A;èÇ?%^Oµ?^G-?CS>^TÔñÏ?f:¯?±??!£?¯ÉÀ^]y?n¬??^OE5Ä}| ,^V)
/S /URI >>
/H /I

>>

(without the hack the URI is plain text)


Unfortunately that is not what it should be...and I am clueless as to what
is going wrong now.  I guess I will have to dive in the encryption part of
the pdf spec to figure out what exactly needs to be encrypted for Acrobat to
be happy with it.

Perhaps someone has suggestions on what might be wrong in the above
Annotation object?

Thanks!

Peter



Peter Coppens wrote:
> 
> Thanks for the prompt feedback. I will try to get my head around the code
> and see whether I can come up with a possible suggestion for a fix
> 
> Peter 
> 
> 
> Andreas Delmelle-2 wrote:
>> 
>> On 29 Nov 2008, at 13:24, Peter Coppens wrote:
>> 
>> Hi Peter
>> 
>>> <snip />
>>> But with encryption options the link is garbled
>>>
>>>  fop -noprint -nocopy  -fo  test.fo  -pdf test.pdf
>>>
>>> When opening in Acrobat reader 8 it pops up a dialog stating
>>>
>>> The document is trying to connect to
>>> file:///private/var/tmp/%1CH%3E%C2%A7%C3%AE%C2%B6%0C%C2%AAcA%C2%91%C2%8En%C2%A7y%C2%90%C3%9F%C2%AAI%C3%A3+%C2%81%C2%AA%3Euk%C3%98%05%C2%B6%C2%91
>> 
>> Seems like this is a known bug (since 0.92) that no one has got around  
>> to fixing yet...
>>   (see also: http://issues.apache.org/show_bug.cgi?id=41959)
>> 
>> 
>> Cheers
>> 
>> Andreas
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Encryption-garbles-external-link-tp20746538p20747833.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Encryption garbles external link

Posted by Peter Coppens <pc...@gmail.com>.
Thanks for the prompt feedback. I will try to get my head around the code and
see whether I can come up with a possible suggestion for a fix

Peter 


Andreas Delmelle-2 wrote:
> 
> On 29 Nov 2008, at 13:24, Peter Coppens wrote:
> 
> Hi Peter
> 
>> <snip />
>> But with encryption options the link is garbled
>>
>>  fop -noprint -nocopy  -fo  test.fo  -pdf test.pdf
>>
>> When opening in Acrobat reader 8 it pops up a dialog stating
>>
>> The document is trying to connect to
>> file:///private/var/tmp/%1CH%3E%C2%A7%C3%AE%C2%B6%0C%C2%AAcA%C2%91%C2%8En%C2%A7y%C2%90%C3%9F%C2%AAI%C3%A3+%C2%81%C2%AA%3Euk%C3%98%05%C2%B6%C2%91
> 
> Seems like this is a known bug (since 0.92) that no one has got around  
> to fixing yet...
>   (see also: http://issues.apache.org/show_bug.cgi?id=41959)
> 
> 
> Cheers
> 
> Andreas
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Encryption-garbles-external-link-tp20746538p20747338.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Encryption garbles external link

Posted by Andreas Delmelle <an...@telenet.be>.
On 29 Nov 2008, at 13:24, Peter Coppens wrote:

Hi Peter

> <snip />
> But with encryption options the link is garbled
>
>  fop -noprint -nocopy  -fo  test.fo  -pdf test.pdf
>
> When opening in Acrobat reader 8 it pops up a dialog stating
>
> The document is trying to connect to
> file:///private/var/tmp/%1CH%3E%C2%A7%C3%AE%C2%B6%0C%C2%AAcA%C2%91%C2%8En%C2%A7y%C2%90%C3%9F%C2%AAI%C3%A3+%C2%81%C2%AA%3Euk%C3%98%05%C2%B6%C2%91

Seems like this is a known bug (since 0.92) that no one has got around  
to fixing yet...
  (see also: http://issues.apache.org/show_bug.cgi?id=41959)


Cheers

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org