Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Geoffry Brown 8 posts 79 karma points
    Dec 08, 2016 @ 17:22
    Geoffry Brown
    1

    SOLVED: Grid issue setting background-image in a grid row

    Good Day All

    With the upgrade yesterday to 7.5.6 there is a bug in the grid when you have the background-image style set on your grid. A utility function was added to bootstap3.cshtml called CleanForXss on line 79:

    var propertyValue = TemplateUtilities.CleanForXss(property.Value.ToString());
    

    well the issue is that this will take the value based on this setting in the grid:

    [ { "label": "Set a background image", "description": "Set a row background", "key": "background-image", "view": "imagepicker", "modifier": "url({0})" } ]

    which creates this based on the url({0}): url(/media/2035/banner1.jpg)

    but right after this utility function is run the value is: urlmedia2035banner1.jpg

    and this gets inserted into the grid row as: style="background-image:urlmedia2035banner1.jpg" which as you probably suspect no longer renders your background.

    debug values

    I will submit a bug for this but for a quick fix just remove the function call:

    var propertyValue = property.Value.ToString();
    

    This will affect any 7.5.6 version. I checked the previous version and it did not have this function call. Not sure why it is added it looks like it is trying to sanitize the string against attack but this data only comes from umbraco backend so not sure why it is required, it is never client entered.

  • Anders Brohus 194 posts 475 karma points
    Jan 12, 2017 @ 07:45
    Anders Brohus
    0

    Got an issue that looks alot like that .. :)

    We'll use the "Headline" grid element, and for an example when the text is

    "We'll help you & support you"

    It will remove the "&" in the text.

    I removed the "TemplateUtilities.CleanForXss" function as well.

    So instead of this

    markup = markup.Replace("#value#", UmbracoHelper.ReplaceLineBreaksForHtml(TemplateUtilities.CleanForXss(Model.value.ToString()))); 
    

    I will look like this

    markup = markup.Replace("#value#", UmbracoHelper.ReplaceLineBreaksForHtml(Model.value.ToString()));
    
  • Geoffry Brown 8 posts 79 karma points
    Jan 12, 2017 @ 13:08
    Geoffry Brown
    0

    Hey Anders.

    You should maybe reopen the bug in the tracker. It is HERE. It is a bit different but I think this will affect anything getting rendered through there. You will have upgrade issues if you fix it yourself, especially if you using Umbraco Cloud.

    Geoff

  • Anders Brohus 194 posts 475 karma points
    Jan 12, 2017 @ 13:24
    Anders Brohus
    0

    Yeah i know i will get issues but i just had to fix it right now .. :)

    This site is not on Cloud so, they are only upgrading when we do it .. :)

  • Geoffry Brown 8 posts 79 karma points
    Jan 12, 2017 @ 13:25
    Geoffry Brown
    0

    I hear ya. I did exactly the same thing ;).

Please Sign in or register to post replies

Write your reply to:

Draft