Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images with spaces in the file name result in broken image on the page #17

Closed
andrew-sbux opened this issue Mar 7, 2016 · 4 comments
Closed
Labels
Milestone

Comments

@andrew-sbux
Copy link

Repro steps:

  • Create image component with a space in the file name
  • Add image component to a page
  • Publish page
  • Verify image is broken
  • Examine image url, has %20 properly encoded

We are using Web8 and DXA 1.3.

@jhorsman
Copy link
Contributor

jhorsman commented Mar 8, 2016

I could reproduce this issue in DXA JAVA 1.2.1 too.
See RWS/dxa-web-application-java#32

@rpannekoek rpannekoek added this to the v1.5 milestone Mar 31, 2016
@rpannekoek rpannekoek added the bug label Mar 31, 2016
@jordanrobinson
Copy link

Hey guys,

I've been trying to debug this a little since we've come across it while developing with the DXA release 1.3. (As far as I can tell the issue should also happen in 1.4).

I've traced this through to the BinaryFileManager class on line 102 of the DXA solution, from here this calls
DateTime lpb = binaryFactory.FindLastPublishedDate(urlPath);

At this point however urlPath has already been encoded (which is a good thing) but between here and what hits the database, the urlPath seems to get unencoded somehow. What this means is that while what is passed into that method is /images/tree%20mid_tcm13-3219.jpg the actual query that hits the db comes out as

declare @p1 int
set @p1=1
exec sp_prepexec @p1 output,N'@P0 int,@P1 nvarchar(4000)',N'select binaryvari0_.BINARY_ID as BINARY_I1_0_, binaryvari0_.PUBLICATION_ID as PUBLICAT2_0_, binaryvari0_.VARIANT_ID as VARIANT_3_0_, binaryvari0_.TYPE as TYPE4_0_, binaryvari0_.IS_COMPONENT as IS_COMPO5_0_, binaryvari0_.DESCRIPTION as DESCRIPT6_0_, binaryvari0_.PATH as PATH7_0_, binaryvari0_.URL as URL8_0_ from BINARYVARIANTS binaryvari0_ where binaryvari0_.PUBLICATION_ID=@P0 
and lower(binaryvari0_.URL)=@P1                ',13,N'/images/tree mid_tcm13-3219.jpg'
select @p1

Where you'll notice the path has been unencoded back to having a space in. This then of course fails, since the path in the database is encoded and it can't find a path that isn't encoded.

So to go back to the initial DXA code, it calls off to the SDLWeb8 DD4T provider, which I believe is the one found here: https://github.com/dd4t/DD4T.Providers.SDLWeb8.CIL

The relevant calls come from the GetBinaryByUrl method in the TridionBinaryProvider, which tries to encode the url again. While this is unnecessary, it isn't the cause of the issue, as the url and the encoded url are at this point the same. (Shown here)

2016-05-19 10_36_20-dd4t providers sdlweb8 cil debugging - microsoft visual studio administrator

The issue as far as I can see is that after this the url is passed to the tridion BinaryMetaFactory (Tridion.ContentDelivery.Meta.BinaryMetaFactory) which seems to unencode the string back into containing spaces before it hits the database and results in the query above.

Any questions on this please let me know.

Thanks,
Jordan

@rpannekoek
Copy link
Contributor

Thanks for your analysis; this is very useful input! Indeed, the problem seems to be in SDL Web 8 CIL/CIS rather than in DXA/DD4T code base. It might be possible to work-around with double encoding, but that would be creating a bug to fix another bug.

@rpannekoek
Copy link
Contributor

Fixed in DXA 1.5 / CIL 8.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants