Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Within our SharePoint 2010 farm running over SSL, we have multiple RSS feeds that are delivered through http://. The issue arises when these RSS feeds have an image and IE displays the warning of insecure content being present. Is there an easy way within the RSS Viewer's XSLT markup to remove all image tags and their contents? These are the two sections that call and display the description HTML within the RSS Viewer Web Part.

 <xsl:if test="string-length(description) &gt; 0">
                <xsl:variable name="SafeHtml">
                    <xsl:call-template name="GetSafeHtml">
                        <xsl:with-param name="Html" select="description"/>
                    </xsl:call-template>
                </xsl:variable>
                 - <xsl:value-of select="$SafeHtml" disable-output-escaping="yes"/>
            </xsl:if>


  <xsl:template name="GetSafeHtml" match="@*|node()>
        <xsl:param name="Html"/>
        <xsl:choose>
            <xsl:when test="$rss_IsDesignMode = 'True'">
                 <xsl:value-of select="$Html"/>
            </xsl:when>
            <xsl:otherwise>
                 <xsl:value-of select="rssaggwrt:MakeSafe($Html)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
share|improve this question
    
I'm not sure that it is a SharePoint question, but xslt :) I think this is more for StackOverflow, they have great xslt guys there. –  Andrey Markeev Apr 29 '11 at 22:35
add comment

3 Answers

Please, check out this articles:

  1. Remove all <img ... /> tags - very elegant xslt solution to remove img tags.
  2. Stripping HTML tags when using XSLT - this can be a demonstration of another approach (most likely, you can simply replace &lt; to &lt;img there to get this templates working for your situation)
share|improve this answer
add comment

You were on the right track with potentially modifying GetSafeHtml :) I resolved this issue using a small tweak to said XSL in the SharePoint RSS Web Part here:

Stop mixed content warnings in SharePoint's RSS Web Part

Basically, you paste over the GetSafeHtml template with a slightly modified version that calls a strip-tags template.

    <xsl:template name="GetSafeHtml">
        <xsl:param name="Html"/>
        <xsl:choose>
            <xsl:when test="$rss_IsDesignMode = 'True'">
                <xsl:call-template name="strip-tags">
                    <xsl:with-param name="text" select="$Html"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="strip-tags">
                    <xsl:with-param name="text" select="rssaggwrt:MakeSafe($Html)"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="strip-tags">
        <xsl:param name="text"/>
        <xsl:choose>
            <xsl:when test="contains($text, '&lt;')">
                <xsl:value-of select="substring-before($text, '&lt;')"/>
                <xsl:call-template name="strip-tags">
                    <xsl:with-param name="text" select="substring-after($text, '&gt;')"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$text"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
share|improve this answer
add comment

I'm pretty sure that you won't easily be able to remove image tags from the RSS feeds but with some digging with Reflector you might find an alternative. Dive into the effectively undocumented ddwrt namespace and find the functions available. There is some very old information on this available from Microsoft.

I bet that there is another function that can be called instead of "rssaggwrt:MakeSafe($Html)". At the very least, it may have some string replacement functions that would allow you to replace the http:// with just // so that images would follow the current protocol.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.