Skip to content

Commit a9cb999

Browse files
authored
Merge pull request #15 from contentstack/bug/image-src-to-url
Image link and embed tag support for attribute url added
2 parents d0cf774 + 3cd4f42 commit a9cb999

File tree

7 files changed

+111
-9
lines changed

7 files changed

+111
-9
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
The MIT License (MIT)
22

33

4-
Copyright (c) 2016-2021 Contentstack
4+
Copyright (c) 2016-2022 Contentstack
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal

SECURITY.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Security
2+
3+
Contentstack takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations.
4+
5+
If you believe you have found a security vulnerability in any Contentstack-owned repository, please report it to us as described below.
6+
7+
## Reporting Security Issues
8+
9+
**Please do not report security vulnerabilities through public GitHub issues.**
10+
11+
Send email to [security@contentstack.com](mailto:security@contentstack.com).
12+
13+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message.
14+
15+
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
16+
17+
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
18+
* Full paths of source file(s) related to the manifestation of the issue
19+
* The location of the affected source code (tag/branch/commit or direct URL)
20+
* Any special configuration required to reproduce the issue
21+
* Step-by-step instructions to reproduce the issue
22+
* Proof-of-concept or exploit code (if possible)
23+
* Impact of the issue, including how an attacker might exploit the issue
24+
25+
This information will help us triage your report more quickly.
26+
27+
[https://www.contentstack.com/trust/](https://www.contentstack.com/trust/)

__test__/json-to-html.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ import {
1414
orderListJson,
1515
unorderListJson,
1616
imgJson,
17+
imgJsonURL,
1718
tableJson,
1819
blockquoteJson,
1920
codeJson,
20-
linkInPJson} from './mock/json-element-mock'
21+
linkInPJson,
22+
linkInPJsonUrl} from './mock/json-element-mock'
2123
import {
2224
blockquoteHtml,
2325
codeHtml,
@@ -350,7 +352,7 @@ describe('Node parse image content', () => {
350352
uid: 'entry_uid_19',
351353
supercharged_rte: [
352354
{
353-
...imgJson
355+
...imgJsonURL
354356
}
355357
],
356358
_embedded_items: {}
@@ -477,7 +479,7 @@ describe('Node parse link in paragraph content', () => {
477479
uid: 'entry_uid_19',
478480
supercharged_rte: [
479481
{
480-
...linkInPJson
482+
...linkInPJsonUrl
481483
},
482484
],
483485
_embedded_items: {}

__test__/mock/json-element-mock.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,32 @@ const imgJson = {
348348
type: "doc"
349349
}
350350

351+
const imgJsonURL = {
352+
uid: "06e34a7a4849d7fc2acd",
353+
_version: 13,
354+
attrs: {},
355+
children: [
356+
{
357+
"uid": "f3be74be3b64646e626",
358+
"type": "img",
359+
"attrs": {
360+
"url": "https://image.url/Donald.jog.png",
361+
"width": 33.69418132611637,
362+
"height": "auto",
363+
"redactor-attributes": {
364+
"asset_uid": "47f1aa5ae422cd1"
365+
}
366+
},
367+
"children": [
368+
{
369+
"text": ""
370+
}
371+
]
372+
}
373+
],
374+
type: "doc"
375+
}
376+
351377
const paragraphJson = {
352378
uid: "0d7fd",
353379
_version: 13,
@@ -610,6 +636,51 @@ const linkInPJson = {
610636
type: "doc"
611637
}
612638

639+
640+
const linkInPJsonUrl = {
641+
uid: "06e34a7190849d7f2acd",
642+
_version: 13,
643+
attrs: {},
644+
children: [
645+
{
646+
"type": "ps",
647+
"attrs": {
648+
"style": {
649+
"text-align": "left"
650+
},
651+
"redactor-attributes": {}
652+
},
653+
"uid": "d88dcdf4590dff2d",
654+
"children": [
655+
{
656+
"text": "",
657+
"bold": true,
658+
"italic": true,
659+
"underline": true,
660+
"subscript": true
661+
},
662+
{
663+
"uid": "0d06598201aa8b47",
664+
"type": "a",
665+
"attrs": {
666+
"url": "LINK.com",
667+
"target": "_self"
668+
},
669+
"children": [
670+
{
671+
"text": "LINK"
672+
}
673+
]
674+
},
675+
{
676+
"text": ""
677+
}
678+
]
679+
}
680+
],
681+
type: "doc"
682+
}
683+
613684
const assetReferenceJson = {
614685
uid: "node_uid_12",
615686
_version: 1,
@@ -954,9 +1025,11 @@ export {
9541025
h5Json,
9551026
h6Json,
9561027
imgJson,
1028+
imgJsonURL,
9571029
codeJson,
9581030
tableJson,
9591031
linkInPJson,
1032+
linkInPJsonUrl,
9601033
plainTextJson,
9611034
paragraphJson,
9621035
orderListJson,

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/utils",
3-
"version": "1.1.0",
3+
"version": "1.1.2",
44
"description": "Contentstack utilities for Javascript",
55
"main": "dist/index.es.js",
66
"types": "dist/types/index.d.ts",

src/options/default-node-options.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ export const defaultNodeOption: RenderOption = {
1111
return `<p>${next(node.children)}</p>`
1212
},
1313
[NodeType.LINK]:(node: Node, next: Next) => {
14-
return `<a href="${node.attrs.href}">${next(node.children)}</a>`
14+
return `<a href="${node.attrs.href || node.attrs.url}">${next(node.children)}</a>`
1515
},
1616
[NodeType.IMAGE]:(node: Node, next: Next) => {
17-
return `<img src="${node.attrs.src}" />${next(node.children)}`
17+
return `<img src="${node.attrs.src || node.attrs.url}" />${next(node.children)}`
1818
},
1919
[NodeType.EMBED]:(node: Node, next: Next) => {
20-
return `<iframe src="${node.attrs.src}">${next(node.children)}</iframe>`
20+
return `<iframe src="${node.attrs.src || node.attrs.url}">${next(node.children)}</iframe>`
2121
},
2222
[NodeType.HEADING_1]:(node: Node, next: Next) => {
2323
return `<h1>${next(node.children)}</h1>`

0 commit comments

Comments
 (0)