Преглед на файлове

Fix greedy parsing of section name

Issue noticed for the transformation of a template for familywall.com,
using MustacheJS 0.3.0. In the anonymous function(match,type,name,content)
in render_section, the name of the section was incorrectly recognized as:

place}} <dd class="field"> <strong>{{#i18n

within a match where the same string is repeated after a / at the end:

{{#place}} <dd class="field"> <strong>{{#i18n}}event.where_event_form{{/i18n}}</strong> <span class="hide" data-field="placeId">{{placeId}}</span> <span>{{name}}</span> </dd> {{/place}} <dd class="field"> <strong>{{#i18n}}

This is an unlikely bug, due to the use of the greedy operator + instead of
its non-greedy counterpart +?.
tags/0.4.1
Eric BRECHEMIER преди 14 години
родител
ревизия
01d01562e6
променени са 2 файла, в които са добавени 5 реда и са изтрити 1 реда
  1. +4
    -0
      CHANGES.md
  2. +1
    -1
      mustache.js

+ 4
- 0
CHANGES.md Целия файл

@@ -1,5 +1,9 @@
# mustache.js Changes # mustache.js Changes


## 0.4.0-dev-familywall (2/9/2012)

* fixed greedy parsing of section name in regexp

## 0.4.0 (1/4/2012) ## 0.4.0 (1/4/2012)


## 0.3.1-dev-twitter-b (8/23/2011) ## 0.3.1-dev-twitter-b (8/23/2011)


+ 1
- 1
mustache.js Целия файл

@@ -176,7 +176,7 @@ var Mustache = function () {
"^([\\s\\S]*?)" + // all the crap at the beginning that is not {{*}} ($1) "^([\\s\\S]*?)" + // all the crap at the beginning that is not {{*}} ($1)


otag + // {{ otag + // {{
"(\\^|\\#)\\s*(.+)\\s*" + // #foo (# == $2, foo == $3)
"(\\^|\\#)\\s*(.+?)\\s*" +// #foo (# == $2, foo == $3), not greedy
ctag + // }} ctag + // }}


"\n*([\\s\\S]*?)" + // between the tag ($2). leading newlines are dropped "\n*([\\s\\S]*?)" + // between the tag ($2). leading newlines are dropped


Loading…
Отказ
Запис