Skip to content

Commit

Permalink
Fixes #268, no guard clause checking to ensure "name" or "HtmlHelper"…
Browse files Browse the repository at this point in the history
… dictionary keys exist before they are used.
  • Loading branch information
NightOwl888 committed Jan 29, 2014
1 parent fbf33af commit fc1d93c
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,28 @@ public override bool IsVisible(ISiteMapNode node, IDictionary<string, object> so
}
visibility = visibility.Trim();

// Check for the source HtmlHelper
if (sourceMetadata["HtmlHelper"] == null)
string name = string.Empty;
string htmlHelper = string.Empty;
if (sourceMetadata.ContainsKey("name"))
{
name = Convert.ToString(sourceMetadata["name"]);
}
if (sourceMetadata.ContainsKey("HtmlHelper"))
{
htmlHelper = Convert.ToString(sourceMetadata["HtmlHelper"]);
}

// Check for the source HtmlHelper or given name. If neither are configured,
// then always visible.
if (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(htmlHelper))
{
return true;
}
string name = Convert.ToString(sourceMetadata["name"]);
string htmlHelper = Convert.ToString(sourceMetadata["HtmlHelper"]);

// Chop off the namespace
htmlHelper = htmlHelper.Substring(htmlHelper.LastIndexOf(".") + 1);

// Get the keywords
var visibilityKeywords = visibility.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);

// All set. Now parse the visibility variable.
Expand Down

0 comments on commit fc1d93c

Please sign in to comment.