Skip to content

Commit 57a6727

Browse files
Merge pull request #9 from contentstack/development
- Jsoup bump vulnerability issue
2 parents 180417c + 322d7ea commit 57a6727

File tree

10 files changed

+244
-75
lines changed

10 files changed

+244
-75
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ If you are using Contentstack Java SDK, then the Utils SDK is already imported i
3232
</dependency>
3333
```
3434

35-
Download [{latest}](https://search.maven.org/artifact/com.contentstack.sdk/utils) dependency here
35+
Download [Latest](https://central.sonatype.dev/artifact/com.contentstack.sdk/utils/) dependency here
3636

3737
### Usage
3838

pom.xml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.contentstack.sdk</groupId>
77
<artifactId>utils</artifactId>
8-
<version>{$utils.version}</version>
8+
<version>1.2.0-SNAPSHOT</version>
99
<packaging>jar</packaging>
1010
<name>Contentstack-utils</name>
1111
<description>Java Utils SDK for Contentstack Content Delivery API, Contentstack is a headless CMS with an API-first
@@ -14,7 +14,6 @@
1414
<url>https://www.***REMOVED***</url>
1515

1616
<properties>
17-
<util.version>1.1.2-SNAPSHOT</util.version>
1817
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1918
<project.reporting.sourceEncoding>UTF-8</project.reporting.sourceEncoding>
2019
<maven.compiler.source>1.8</maven.compiler.source>
@@ -24,7 +23,7 @@
2423
<maven-source-plugin.version>2.2.1</maven-source-plugin.version>
2524
<maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version>
2625
<junit.version>4.13.2</junit.version>
27-
<jsoup.version>1.14.3</jsoup.version>
26+
<jsoup.version>1.15.3</jsoup.version>
2827
<json.simple.version>1.1.1</json.simple.version>
2928
<maven-site-plugin.version>3.3</maven-site-plugin.version>
3029
<maven-gpg-plugin.version>1.5</maven-gpg-plugin.version>
@@ -104,12 +103,12 @@
104103
<groupId>com.googlecode.json-simple</groupId>
105104
<artifactId>json-simple</artifactId>
106105
<version>${json.simple.version}</version>
107-
<scope>compile</scope>
106+
<scope>provided</scope>
108107
</dependency>
109108
<dependency>
110109
<groupId>org.springframework</groupId>
111110
<artifactId>spring-web</artifactId>
112-
<version>5.3.20</version>
111+
<version>5.3.23</version>
113112
<scope>compile</scope>
114113
</dependency>
115114
</dependencies>
@@ -206,7 +205,7 @@
206205
<plugin>
207206
<groupId>org.sonatype.plugins</groupId>
208207
<artifactId>nexus-staging-maven-plugin</artifactId>
209-
<version>1.6.7</version>
208+
<version>1.6.13</version>
210209
<extensions>true</extensions>
211210
<configuration>
212211
<serverId>ossrh</serverId>

src/main/java/com/contentstack/utils/Utils.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,47 @@ public static void jsonToHTML(@NotNull JSONObject entry, @NotNull String[] keyPa
181181
}
182182

183183

184+
/**
185+
* Converts jsonRTE to String
186+
*
187+
* @param jsonRTE
188+
* The JsonRTE object {@link JSONObject}
189+
* @param renderOption
190+
* The Option Interface
191+
* @param embeddeditems
192+
* The Embedded Objects {@link JSONObject}
193+
* @return String
194+
*/
195+
public static String jsonToHTML(@NotNull JSONObject jsonRTE, Option renderOption, JSONObject embeddeditems) {
196+
MetaToEmbedCallback converter = metadata -> {
197+
if (embeddeditems != null && !embeddeditems.isEmpty()) {
198+
return findEmbeddedItems(embeddeditems, metadata);
199+
}
200+
return Optional.empty();
201+
};
202+
return enumerateContent(jsonRTE, renderOption, converter);
203+
}
204+
205+
/**
206+
* @param jsonRTE
207+
* The JsonRTE Array {@link JSONArray}
208+
* @param renderOption
209+
* The Option Interface
210+
* @param embeddeditems
211+
* The Embedded Objects {@link JSONObject}
212+
* @return String
213+
*/
214+
public static Object jsonToHTML(@NotNull JSONArray jsonRTE, Option renderOption, JSONObject embeddeditems) {
215+
MetaToEmbedCallback converter = metadata -> {
216+
if (embeddeditems != null && !embeddeditems.isEmpty()) {
217+
return findEmbeddedItems(embeddeditems, metadata);
218+
}
219+
return Optional.empty();
220+
};
221+
return enumerateContents(jsonRTE, renderOption, converter);
222+
}
223+
224+
184225
/**
185226
* Render.
186227
*

src/main/java/com/contentstack/utils/helper/Metadata.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,20 @@ public class Metadata {
1717
/**
1818
* Instantiates a new Metadata.
1919
*
20-
* @param text the text
21-
* @param itemType the item type
22-
* @param itemUid the item uid
23-
* @param contentTypeUid the content type uid
24-
* @param styleType the style type
25-
* @param outerHTML the outer html
26-
* @param attributes the attributes
20+
* @param text
21+
* the text
22+
* @param itemType
23+
* the item type
24+
* @param itemUid
25+
* the item uid
26+
* @param contentTypeUid
27+
* the content type uid
28+
* @param styleType
29+
* the style type
30+
* @param outerHTML
31+
* the outer html
32+
* @param attributes
33+
* the attributes
2734
*/
2835
public Metadata(String text, String itemType, String itemUid, String contentTypeUid,
2936
String styleType, String outerHTML, Attributes attributes) {

src/main/java/com/contentstack/utils/interfaces/Option.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,34 @@ public interface Option {
1212
/**
1313
* Render options string.
1414
*
15-
* @param embeddedObject the embedded object
16-
* @param metadata the metadata
15+
* @param embeddedObject
16+
* the embedded object
17+
* @param metadata
18+
* the metadata
1719
* @return the string
1820
*/
1921
String renderOptions(JSONObject embeddedObject, Metadata metadata);
2022

2123
/**
2224
* Render mark string.
2325
*
24-
* @param markType the mark type
25-
* @param renderText the render text
26+
* @param markType
27+
* the mark type
28+
* @param renderText
29+
* the render text
2630
* @return the string
2731
*/
2832
String renderMark(MarkType markType, String renderText);
2933

3034
/**
3135
* Render node string.
3236
*
33-
* @param nodeType the node type
34-
* @param nodeObject the node object
35-
* @param callback the callback
37+
* @param nodeType
38+
* the node type
39+
* @param nodeObject
40+
* the node object
41+
* @param callback
42+
* the callback
3643
* @return the string
3744
*/
3845
String renderNode(String nodeType, JSONObject nodeObject, NodeCallback callback);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.contentstack.utils;
2+
3+
public class RTEResult {
4+
5+
public static String kParagraphHtml = "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed condimentum iaculis magna in vehicula. Vestibulum vitae convallis lacus. Praesent a diam iaculis turpis rhoncus faucibus. Aliquam sed pulvinar sem.</p>";
6+
public static String kPlainTextHtml = "<strong>Aliquam sit amet libero dapibus, eleifend ligula at, varius justo</strong><strong><em>Lorem ipsum</em></strong><strong><em><u>dolor sit amet</u></em></strong><strong><em><u><strike>consectetur adipiscing elit.</strike></u></em></strong><strong><em><u><span>Sed condimentum iaculis magna in vehicula. </span></u></em></strong><strong><em><u><sup> Vestibulum vitae convallis </sup></u></em></strong><strong><em><u><sub> lacus. </sub></u></em></strong>";
7+
public static String kH1Html = "<h1><strong><em><u><sub>Lorem ipsum dolor sit amet.</sub></u></em></strong></h1>";
8+
public static String kH2Html = "<h2><strong><em><u><sub>Vestibulum a ligula eget massa sagittis aliquam sit amet quis tortor. </sub></u></em></strong></h2>";
9+
public static String kH3Html = "<h3><strong><em><u><sub>Mauris venenatis dui id massa sollicitudin, non bibendum nunc dictum.</sub></u></em></strong></h3>";
10+
public static String kH4Html = "<h4><strong><em><u><sub>MaNullam feugiat turpis quis elit interdum, vitae laoreet quam viverra</sub></u></em></strong></h4>";
11+
public static String kH5Html = "<h5>Mauris venenatis dui id massa sollicitudin, non bibendum nunc dictum.</h5>";
12+
public static String kH6Html = "<h6>Nunc porta diam vitae purus semper, ut consequat lorem vehicula.</h6>";
13+
public static String kOrderListHtml = "<ol><li>Morbi in quam molestie, fermentum diam vitae, bibendum ipsum.</li><li>Pellentesque mattis lacus in quam aliquam congue</li><li>Integer feugiat leo dignissim, lobortis enim vitae, mollis lectus.</li><li>Sed in ante lacinia, molestie metus eu, fringilla sapien.</li></ol>";
14+
public static String kIUnorderListHtml = "<ul><li>Sed quis metus sed mi hendrerit mollis vel et odio.</li><li>Integer vitae sem dignissim, elementum libero vel, fringilla massa.</li><li>Integer imperdiet arcu sit amet tortor faucibus aliquet.</li><li>Aenean scelerisque velit vitae dui vehicula, at congue massa sagittis.</li></ul>";
15+
public static String kImgHtml = "<img src=\"https://images.***REMOVED***/v3/assets/UID_13/Donald.jog.png\" />";
16+
public static String kTableHtml = "<table><thead><tr><th><p>Header 1</p></th><th><p>Header 2</p></th></tr></thead><tbody><tr><td><p>Body row 1 data 1</p></td><td><p>Body row 1 data 2</p></td></tr><tr><td><p>Body row 2 data 1</p></td><td><p>Body row 2 data 2</p></td></tr></tbody></table>";
17+
public static String kBlockquoteHtml = "<blockquote>Praesent eu ex sed nibh venenatis pretium.</blockquote>";
18+
public static String kCodeHtml = "<code>Code template.</code>";
19+
public static String kLinkInPHtml = "<p><strong><em><u><sub></sub></u></em></strong><a href=\"LINK.com\">LINK</a></p>";
20+
public static String kEmbedHtml = "<iframe src=\"https://www.youtube.com/watch?v=AOP0yARiW8U\"></iframe>";
21+
}

0 commit comments

Comments
 (0)