Skip to content

Commit 856e33f

Browse files
committed
bug fixed in replace and replace all not to call replacement to replace empty string to something that will cause memory overflow error
1 parent 6d0aeb5 commit 856e33f

20 files changed

Lines changed: 32 additions & 21 deletions

File tree

.mvn/touch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
000
1+
1744788460863

README.jrf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is a Jamal reference file containing serialized base64 encoded macros
2-
# Created: 2025-03-12 13:08:36 +0100
2+
# Created: 2025-04-16 09:25:54 +0200
33
# id|openStr|closeStr|verbatim|tailParameter|pure|content|parameters
44
# TOC
55
VE9D|eyU=|JX0=|0|0|0|Ci4gPDxJbnN0YWxsYXRpb24+PgouIDw8R1M+PgouIDw8Q29uZmlndXJhdGlvbj4+Ci4gPDxGZWF0dXJlcz4+Ci4gPDxDb250cmlidXRpbmc+PgouIDw8RG9jdW1lbnRhdGlvbj4+Ci4gPDxMaWNlbnNlPj4KLiA8PENoYW5nZWxvZz4+Ci4gPDxSb2FkbWFwPj4KLiA8PFN1cHBvcnQ+PgouIDw8RkFRPj4KLiA8PE1haW50ZW5hbmNlPj4=|

documentation/macros/env.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ is
2020
.output
2121
[source]
2222
----
23-
/Users/verhasp/.sdkman/candidates/java/21.0.1-oracle
23+
/Users/verhasp/.sdkman/candidates/java/21.0.6-oracle
2424
----
2525

2626

jamal-json/README.adoc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77

88
Using this integration module, you can mix Jamal macro text with JSON data.
9-
To use this module, you have to add the dependency to your Maven project, as:
9+
10+
The module is included in the standard versions of Jamal, so you can use it right out of the box.
11+
12+
If you create your own Jamal Java integration, you have to add the dependency to your Maven project, as:
1013
[source,xml]
1114
----
1215
<dependency>
@@ -39,9 +42,9 @@ These differences come from the different nature of Json and Yaml.
3942

4043
[[define]]
4144
=== i. `json:define`
42-
You can use this macro to define a JSon structure.
45+
You can use this macro to define a JSON structure.
4346
A JSON structure can be a map, a list or a string.
44-
JSon supports other primitive values, but Jamal being a text macro processor handles all other primitive types as strings.
47+
JSON supports other primitive values, but Jamal being a text macro processor handles all other primitive types as strings.
4548

4649
The format of the macro is
4750

jamal-json/README.adoc.jam

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
{%#counter:define id=macroChapter {%@define format=$roman. %}%}
77
{%@snip:collect from=src/main/java%}
88
Using this integration module, you can mix Jamal macro text with JSON data.
9-
To use this module, you have to add the dependency to your Maven project, as:
9+
10+
The module is included in the standard versions of Jamal, so you can use it right out of the box.
11+
12+
If you create your own Jamal Java integration, you have to add the dependency to your Maven project, as:
1013
{%@snip:xml pom=pom.xml%}\
1114
{%#define VERSION={%pom /project/version/text()%}%}\
1215
{%#define ARTIFACT_ID={%pom /project/artifactId/text()%}%}\

jamal-json/src/main/java/javax0/jamal/json/Define.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
@Macro.Name("json:define")
1111
public class Define implements Macro, InnerScopeDependent, Scanner {
1212
/* snippet Define_macro_documentation
13-
You can use this macro to define a JSon structure.
13+
You can use this macro to define a JSON structure.
1414
A JSON structure can be a map, a list or a string.
15-
JSon supports other primitive values, but Jamal being a text macro processor handles all other primitive types as strings.
15+
JSON supports other primitive values, but Jamal being a text macro processor handles all other primitive types as strings.
1616
1717
The format of the macro is
1818

jamal-json/src/main/java/javax0/jamal/json/JsonMacroObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public JsonMacroObject(String id, Object content) {
1818
@Override
1919
public String evaluate(String... parameters) throws BadSyntax {
2020
BadSyntax.when(parameters.length > 1, "JSON object macro can have one argument, a JSONPointer");
21-
if (parameters.length > 0 && parameters[0].trim().length() > 0) {
21+
if (parameters.length > 0 && !parameters[0].trim().isEmpty()) {
2222
try {
2323
final var expression = JsonTools.getPointer(parameters[0].trim());
2424
return String.valueOf(expression.queryFrom(getObject()));

jamal-prog/src/main/java/javax0/jamal/prog/analyzer/Block.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static javax0.jamal.prog.commands.Block analyze(final Lex.List lexes) thr
1616
case "\n":
1717
lexes.next(); // ignore empty lines
1818
break;
19-
// start the block specific analyzers, who will also consume the keyword
19+
// start the block-specific analyzers, who will also consume the keyword
2020
case "if":
2121
commands.add(If.analyze(lexes));
2222
break;

jamal-snippet/README.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,7 +2750,7 @@ The content of the file `simple.jrf` generated below is:
27502750
[source]
27512751
----
27522752
# This is a Jamal reference file containing serialized base64 encoded macros
2753-
# Created: 2025-03-12 12:52:30 +0100
2753+
# Created: 2025-04-16 09:22:45 +0200
27542754
# id|openStr|closeStr|verbatim|tailParameter|pure|content|parameters
27552755
# b
27562756
Yg==|ew==|fQ==|0|0|0|VGhlIHZhbHVlIG9mIGI=|
@@ -3564,7 +3564,7 @@ will result
35643564
- Decorator.java: 9,094 bytes
35653565
- Memoize.java: 9,538 bytes
35663566
- LineCount.java: 500 bytes
3567-
- Replace.java: 3,494 bytes
3567+
- Replace.java: 3,618 bytes
35683568
- SnipLine.java: 640 bytes
35693569
- SnipCheckFailed.java: 775 bytes
35703570
- SemVerCollator.java: 9,016 bytes
@@ -3602,7 +3602,7 @@ will result
36023602
- XmlDocument.java: 6,273 bytes
36033603
- References.java: 9,257 bytes
36043604
- Java.java: 11,187 bytes
3605-
- ReplaceLines.java: 3,269 bytes
3605+
- ReplaceLines.java: 3,405 bytes
36063606
- SkipLines.java: 2,625 bytes
36073607
- SnipCheck.java: 7,367 bytes
36083608
- IdempotencyFailed.java: 1,816 bytes
@@ -3875,7 +3875,7 @@ will result in the output
38753875
.output
38763876
[source]
38773877
----
3878-
2025-03-12 13:08:36
3878+
2025-04-16 09:25:54
38793879
----
38803880

38813881

jamal-snippet/README.adoc.jam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ When there is a match for a `skip`, any further `skip` is ignored until an `endS
13211321

13221322
[[replace]]
13231323
=== {%chapter%}`replace`
1324-
{%#snip:check file={%JAVA_DIR%}Replace.java hash=46d1ed42%}
1324+
{%#snip:check file={%JAVA_DIR%}Replace.java hash=a8d1c988%}
13251325
The macro `replace` replaces strings with other strings in its input.
13261326
{%standardInput%}
13271327

@@ -1367,7 +1367,7 @@ In that case you can switch it off using the option `(detectNoChange=false)` in
13671367

13681368
[[replaceLines]]
13691369
=== {%chapter%}`replaceLines`
1370-
{%#snip:check file={%JAVA_DIR%}ReplaceLines.java hash=cc7dc937%}
1370+
{%#snip:check file={%JAVA_DIR%}ReplaceLines.java hash=cd2eb183%}
13711371
This macro replaces strings in the input.
13721372
{%parameterized%}
13731373

0 commit comments

Comments
 (0)