Skip to content

SafeString ? #660

Closed
Closed

Description

@StefH

Is this new?

Because when I use the new 2.4.0 for this unit test:

{{[String.Append] \"foo\" ([String.Append] \"a\" \"b\")}}

When parsing the arguments, I get a SafeString with value ab, however the SafeString is internal, so I cannot process it.

My Append method is like:

[HandlebarsWriter(WriterType.String)]
public string Append(string value, string append)
{
    if (string.IsNullOrEmpty(value))
    {
        return append;
    }

    if (string.IsNullOrEmpty(append))
    {
        return value;
    }

    return value + append;
}

Activity

  1. StefH commented on Aug 6, 2026

    @StefH
    CollaboratorAuthor

    I think I found it.
    I always used WriteSafeString and the behavior has been changed.
    So probably I can just use Write.

  2. StefH commented on Aug 6, 2026

    @StefH
    CollaboratorAuthor

    Nope...
    Does not matter, my code still fails.

  3. StefH commented on Aug 6, 2026

    @StefH
    CollaboratorAuthor

    Solution for me is:

    private const string SafeStringTypeName = "HandlebarsDotNet.SafeString";
    
    if (argument.GetType().FullName == SafeStringTypeName)
    {
        return argument.ToString();
    }
  4. rexm commented on Aug 7, 2026

    @rexm
    Member

    Thanks for flagging this. Fix in progress.

  5. added a commit that references this issue on Aug 7, 2026
  6. rexm commented on Aug 7, 2026

    @rexm
    Member

    Released under 2.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions