Closed melloware closed 1 day ago
Found a workaround but can't explain why...
It's because CspPartialResponseWriter extends PrimePartialResponseWriter
so PrimePartialResponseWriter#endDocument()
impl, which adds eval scripts, is invoked twice. Make it extend PartialResponseWriter
instead and the problem will go away.
let me test that. thank you.
OK so that fixes Mojarra and break MyFaces. The new result is this...
<?xml version='1.0' encoding='utf-8'?>
<partial-response>
<changes>
<update id="j_id1:javax.faces.ViewState:0"><![CDATA[-8888652108271766523:-9198939220272553376]]></update>
</changes>
<changes>
<eval><![CDATA[if(window.PrimeFaces){PrimeFaces.csp.init('N2QyNTFlYWYtOGM5MS00NjBkLWFkN2EtODExOWVlMDkyMDU4');};;PrimeFaces.download('/javax.faces.resource/dynamiccontent.properties.xhtml?ln=primefaces&v=15.0.0-SNAPSHOT&pfdrid=c07524ce314cee24b9418afbab32a60f&pfdrt=sc&pfdrid_c=false&uid=b4ffba85-2f08-4766-9001-f3fed0f52ba1', 'text/plain', 'default.txt', 'primefaces.download_test');]]></eval>
</changes>
</partial-response>
<?xml version="1.0" encoding="UTF-8"?>
<partial-response id="j_id__v_0">
<changes>
<update id="javax.faces.Resource"><![CDATA[]]></update>
<update id="j_id__v_0:javax.faces.ViewState:1"><![CDATA[ODM4NzY3MzRCMTc2RUY4RDAwMDAwMDAx]]></update>
</changes>
</partial-response>
OK with your help got to the bottom of it the real problem was in PrimePartialViewContent passing the writer into a writer.
Hmm ok probably MyFaces still has a wrapped-vs-getWrapped bug in its ResponseWriter(Wrapper) impl that it fails to invoke the PrimePartialResponseWriter#endDocument when given a wrapped writer.
Agreed I will take a look at MyFaces
Describe the bug
Original Report: https://github.com/primefaces/primefaces/issues/12189
in PrimeFaces 14.0.0 we made this change per @BalusC recommendation: https://github.com/primefaces/primefaces/issues/9518
When using
ajax="true"
andprimefaces.CSP
enabled the FileDownload is executed twice. I have debugged it and it seems to be Mojarra is writing the<changes>
entry twice and MyFaces is only writing it once.Mojarra 4.0.7
MyFaces 4.0.2
Reproducer
pf-12189.zip
Expected behavior
Only 1 file downloaded.
PrimeFaces edition
Community
PrimeFaces version
14.0.1
Theme
No response
JSF implementation
Mojarra
JSF version
2.3
Java version
11