Copied to clipboard

Flag this post as spam?

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

  • Matthew Kirschner 323 posts 606 karma points
    Feb 04, 2015 @ 23:11
    Matthew Kirschner

    FullTextSearch.cshtml does not check for "null" string

    Using the macro tool in the RTE, I added the FullTextSearch macro with default settings. In Umbraco 7.2.1, this creates code that looks like this:

     <?UMBRACO_MACRO macroAlias="FullTextSearch" queryType="null" titleProperties="null" bodyProperties="null" summaryProperties="null" titleLinkProperties="null" rootNodes="null" contextHighlighting="0" summaryLength="null" pageLength="null" fuzzyness="null" useWildcards="0" />

    Notice that the default for each attribute is the text string "null". When the macro view attempts to validate these attributes, it checks for a null value rather than a string with the value "null". Of course, the results did not display without tweaking the macro partial to account for this.

    Here is an example of my fix for the queryType attribute: 

    var queryType = String.IsNullOrEmpty(Parameter.queryType) || Parameter.queryType == "null" ? "MultiRelevance" : Parameter.queryType;

    In this example, I added the line: || Parameter.queryType == "null" to check for string values of null.

Please Sign in or register to post replies

Write your reply to: