@rhinostone/swig-jinja2 2.9.0 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/filters.js +25 -9
- package/lib/index.js +1 -1
- package/package.json +2 -2
package/lib/filters.js
CHANGED
|
@@ -611,11 +611,16 @@ exports.striptags = function (input) {
|
|
|
611
611
|
if (out !== undefined) {
|
|
612
612
|
return out;
|
|
613
613
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
614
|
+
// The comment and tag regexes take time quadratic in the input length on
|
|
615
|
+
// many <!-- or < with no --> or > after them, and the trailing \s+$ on a
|
|
616
|
+
// long run of whitespace; the swig-core helpers give the same output in
|
|
617
|
+
// linear time.
|
|
618
|
+
// return String(input)
|
|
619
|
+
// .replace(/<!--[\s\S]*?-->/g, '')
|
|
620
|
+
// .replace(/<[^>]*>/g, '')
|
|
621
|
+
// .replace(/\s+/g, ' ')
|
|
622
|
+
// .replace(/^\s+|\s+$/g, '');
|
|
623
|
+
return utils.strip(utils.stripTags(utils.stripComments(String(input)), true).replace(/\s+/g, ' '));
|
|
619
624
|
};
|
|
620
625
|
|
|
621
626
|
/**
|
|
@@ -645,9 +650,13 @@ exports.trim = function (input, chars) {
|
|
|
645
650
|
} else {
|
|
646
651
|
pattern = '[' + String(chars).replace(/[\\\[\]\^\-]/g, '\\$&') + ']';
|
|
647
652
|
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
653
|
+
// A pattern + '+$' regex takes quadratic time on a long run of trimmed
|
|
654
|
+
// characters inside the string; trimEnd removes the same code units in
|
|
655
|
+
// linear time.
|
|
656
|
+
// return input
|
|
657
|
+
// .replace(new RegExp('^' + pattern + '+'), '')
|
|
658
|
+
// .replace(new RegExp(pattern + '+$'), '');
|
|
659
|
+
return utils.trimEnd(input.replace(new RegExp('^' + pattern + '+'), ''), pattern === '\\s' ? undefined : String(chars));
|
|
651
660
|
};
|
|
652
661
|
|
|
653
662
|
/**
|
|
@@ -753,7 +762,14 @@ function formatGeneral(num, prec) {
|
|
|
753
762
|
*/
|
|
754
763
|
function sprintf(fmt, args) {
|
|
755
764
|
var idx = 0;
|
|
756
|
-
|
|
765
|
+
// The flags and the width both take zeros, so on a % followed by a long run
|
|
766
|
+
// of zeros and no conversion this regex backtracked over every split,
|
|
767
|
+
// taking quadratic time. Each lookahead below captures its run once and
|
|
768
|
+
// the backreference consumes it, so nothing backtracks; the matches are
|
|
769
|
+
// the same, except that an absent width is "" instead of undefined, which
|
|
770
|
+
// the callback reads the same way.
|
|
771
|
+
// return fmt.replace(/%([-+ 0]*)(\d+)?(?:\.(\d+))?([sdiufFeEgGxXoc%])/g, function (m, flags, width, prec, conv) {
|
|
772
|
+
return fmt.replace(/%(?=([-+ 0]*))\1(?=(\d*))\2(?:\.(?=(\d+))\3)?([sdiufFeEgGxXoc%])/g, function (m, flags, width, prec, conv) {
|
|
757
773
|
var arg, hasPrec, sign, s, num, pad;
|
|
758
774
|
|
|
759
775
|
function withSign(value) {
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhinostone/swig-jinja2",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.1",
|
|
4
4
|
"description": "Jinja2-syntax frontend for the @rhinostone/swig-core template engine. Part of the @rhinostone/swig multi-flavor family.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"template",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"node": ">=12"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@rhinostone/swig-core": "2.9.
|
|
26
|
+
"@rhinostone/swig-core": "2.9.1"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|