0

I'm trying to solve an issue with posting comments for a blog that uses the Weblog Sitecore module. From what I can tell, if the blog entry url contains dashes (i.e. http://[domain.org]/blog/2016/december/test-2-entry), then I get the "End of string expected at line [#]" error. If the blog entry url does NOT contain dashes, then the comment form works fine.

<replace mode="on" find="-" replaceWith="_"/>

Also tried to replace the dash with an empty space. Neither solution has worked as I still get the error.

Is there some other setting in the Web.config I can alter to escape the dashes in the urls? I have read that enclosing dashed url text with the # symbol works, but I'd like to be able to do that automatically instead of having the user go back and rename all their blog entries.

Here is a screenshot of the error for reference:enter image description here

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
Dejsa Cocan
  • 1,539
  • 3
  • 19
  • 56

1 Answers1

3

I have not experience the Weblog module but for the issue you are facing, you should escape the dash with #. Please see the following code snippet:

public string EscapePath(string path)
{
    string[] joints = Regex.Split(path, "/");
    string output = string.Empty;
    for (int index = 0; index < joints.Length; index++)
    {
        string joint = joints[index];
        if (!string.IsNullOrEmpty(joint))
            output += string.Format("#{0}#", joint);

        if (index != joints.Length - 1)
            output += "/";
    }

    return output;
}

Reference: https://github.com/WeTeam/WeBlog/issues/52

More information about escaping dash in queries can be found here

UPDATE

You should call this method before posting the comment for it to escape the dashes. You may also download the dll from here and use it in your solution

Hishaam Namooya
  • 1,071
  • 1
  • 11
  • 22
  • This looks like a good solution but I have no idea where this function should be placed.... – Dejsa Cocan Mar 18 '17 at 19:05
  • As i already provided in the answer, i haven't use the Weblog module. Maybe you can ask on the github page provided in the answer. But i think there must be a pipeline that you can override in the module to add the method – Hishaam Namooya Mar 18 '17 at 19:13
  • If i am not mistaken, check the xml node weblogCreateComment in the weblog.config. I think it is there that you should place the method. I think it should be the first to run – Hishaam Namooya Mar 18 '17 at 19:22