Git Product home page Git Product logo

Comments (10)

soranoba avatar soranoba commented on June 2, 2024

Hi, @dzimi

I think that the backward compatibility is important.
If I change the interface of function, I will do a major update.

However, I think that this case is fix the bug.
(Please check the demo page if necessary)

If it will found different behaviors as demo page, I would regard as bug and fix it.
Therefore, please use the {{{ key }}}, If you do not want to escape in any case.

In addition, escape is specifications of the mustache. So, I am negative that it be added unescape option...

from bbmustache.

dzimi avatar dzimi commented on June 2, 2024

Thanks, I get it. The slash char was not escaped in previous versions and it was a bug. I made an issue on rebar3 erlang/rebar3#1264. Due to this bug in < v1.1.0, is quite risky to upgrade the bbmustache version, because path variables in form {{ path }} will be escaped. But it is the problem of rebar3 ...

from bbmustache.

filmor avatar filmor commented on June 2, 2024

Couldn't you just make this behaviour optional? Why do you need to escape slashes anyhow?

from bbmustache.

soranoba avatar soranoba commented on June 2, 2024

@filmor
bbmustache must conform to the specifications of the mustache.

If bbmustache has the option, it will happen that someone want to escape and use the {{key}}, but generated text is not escape (In other words, contrary to the specification !!).
So, when I allow this, bbmustache won't be worth.

from bbmustache.

dzimi avatar dzimi commented on June 2, 2024

I agree with @soranoba. I think that this issue can be closed and issue erlang/rebar3#1264 should be resloved instead.

from bbmustache.

soranoba avatar soranoba commented on June 2, 2024

That's right. I will close this issue. thanks!!

from bbmustache.

filmor avatar filmor commented on June 2, 2024

Wait a second, where in the spec does it say, that the forward slash is to be escaped? Here it actually states (as it makes sense) that only & " < > are to be escaped.

Also, the reference implementation allows you to override escaping rules: https://github.com/mustache/mustache/blob/master/lib/mustache.rb#L205

And the function it uses by default (http://ruby-doc.org/stdlib-1.9.3/libdoc/cgi/rdoc/CGI.html#method-c-escapeHTML) escapes only & " < >.

In fact, your current implementation is not implementing the spec correctly, you are escaping far too many things.

from bbmustache.

soranoba avatar soranoba commented on June 2, 2024

@filmor
Thank you for the information.
I trust the man page and the demo page, and did not look at the spec.
Sorry, it is my mistake.

I will make the modification in accordance with the spec.
(It also included other than html escaping.)

@dzimi
Do you is also good with this?

from bbmustache.

dzimi avatar dzimi commented on June 2, 2024

@filmor : great job ! The demo version works with mustache.js which escapes following characters:

  var entityMap = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': '&quot;',
"'": '&#39;',
**"/": '&#x2F;'**

};

Ruby :

TABLE_FOR_ESCAPE_HTML__ = {
"'" => '&#39;',
'&' => '&amp;',
'"' => '&quot;',
'<' => '&lt;',
'>' => '&gt;',

}

Python:

def escape(s, quote=True):
"""
Replace special characters "&", "<" and ">" to HTML-safe sequences.
If the optional flag quote is true (the default), the quotation mark
characters, both double quote (") and single quote (') characters are also
translated.
"""
s = s.replace("&", "&amp;") # Must be done first!
s = s.replace("<", "&lt;")
s = s.replace(">", "&gt;")
if quote:
    s = s.replace('"', "&quot;")
    s = s.replace('\'', "&#x27;")
return s

As you can see , Ruby and Python does not escpae "/" , but js does. I think the strongest argument is the spec . So I agree with @filmor , lets straighten it out.

from bbmustache.

soranoba avatar soranoba commented on June 2, 2024

I fix this.
Please use the v1.2.0.
https://github.com/soranoba/bbmustache/releases/tag/v1.2.0

from bbmustache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.