Skip to content

Commit 194151e

Browse files
committed
Secrets removed from test
1 parent 199bf8f commit 194151e

13 files changed

Lines changed: 1923 additions & 5 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ coverage
77
\.yardoc
88
.DS_Store
99
.bundle/
10-
**/rspec_results.html
10+
**/rspec_results.html
11+
.dccache

LICENSE

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

3-
Copyright (c) 2012-2021 Contentstack. All Rights Reserved
3+
Copyright (c) 2012-2022 Contentstack. All Rights Reserved
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
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/)

lib/contentstack_utils/model/options.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ def render_node(node_type, node, inner_html)
6060
when 'p'
6161
renderString = "<p>#{inner_html}</p>"
6262
when 'a'
63-
renderString = "<a href='#{node["attrs"]["href"] || ""}'>#{inner_html}</a>"
63+
renderString = "<a href='#{node["attrs"]["href"] || node["attrs"]["url"] || ""}'>#{inner_html}</a>"
6464
when 'img'
65-
renderString = "<img src='#{node["attrs"]["src"] || ""}' />#{inner_html}"
65+
renderString = "<img src='#{node["attrs"]["src"] || node["attrs"]["url"] || ""}' />#{inner_html}"
6666
when 'embed'
67-
renderString = "<iframe src='#{node["attrs"]["src"] || ""}'></iframe>"
67+
renderString = "<iframe src='#{node["attrs"]["src"] || node["attrs"]["url"] || ""}'></iframe>"
6868
when 'h1'
6969
renderString = "<h1>#{inner_html}</h1>"
7070
when 'h2'

spec/lib/model/metadata_spec.rb

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
require 'spec_helper'
2+
3+
RSpec.describe ContentstackUtils::Model::Metadata do
4+
describe ' Metadata test' do
5+
it 'Blank attributes' do
6+
characters = getElement('<h1>TEST</h1>', "//h1")
7+
characters.each do |n|
8+
metadata = ContentstackUtils::Model::Metadata.new(n)
9+
expect(metadata.item_type).to eq nil
10+
expect(metadata.style_type).to eq nil
11+
expect(metadata.item_uid).to eq nil
12+
expect(metadata.content_type_uid).to eq nil
13+
expect(metadata.text).to eq 'TEST'
14+
end
15+
end
16+
17+
it 'Wrong attributes' do
18+
characters = getElement('<h1 type="" sys-style-type="" data-sys-entry-uid="" data-sys-content-type-uid="">TEST</h1>', "//h1")
19+
characters.each do |n|
20+
metadata = ContentstackUtils::Model::Metadata.new(n)
21+
expect(metadata.item_type).to eq ""
22+
expect(metadata.style_type).to eq ""
23+
expect(metadata.item_uid).to eq ""
24+
expect(metadata.content_type_uid).to eq ""
25+
expect(metadata.text).to eq 'TEST'
26+
end
27+
end
28+
29+
it 'Attributes' do
30+
characters = getElement('<h1 type="asset" sys-style-type="inline" data-sys-entry-uid="uid" data-sys-content-type-uid="contentType">
31+
TEST</h1>', "//h1")
32+
characters.each do |n|
33+
metadata = ContentstackUtils::Model::Metadata.new(n)
34+
expect(metadata.item_type).to eq "asset"
35+
expect(metadata.style_type).to eq "inline"
36+
expect(metadata.item_uid).to eq "uid"
37+
expect(metadata.content_type_uid).to eq "contentType"
38+
expect(metadata.text).to eq '
39+
TEST'
40+
end
41+
end
42+
43+
it 'Asset Uid Attributes' do
44+
characters = getElement('<h1 type="asset" sys-style-type="inline" data-sys-asset-uid="assetuid">TEST</h1>', "//h1")
45+
characters.each do |n|
46+
metadata = ContentstackUtils::Model::Metadata.new(n)
47+
expect(metadata.item_type).to eq "asset"
48+
expect(metadata.style_type).to eq "inline"
49+
expect(metadata.item_uid).to eq "assetuid"
50+
expect(metadata.content_type_uid).to eq nil
51+
expect(metadata.text).to eq 'TEST'
52+
end
53+
end
54+
55+
it 'Asset Json To metadata' do
56+
doc = getJson(AssetReferenceJson)
57+
metadata = ContentstackUtils::Model::Metadata.new(doc["children"][0])
58+
expect(metadata.item_type).to eq "asset"
59+
expect(metadata.style_type).to eq "display"
60+
expect(metadata.item_uid).to eq "asset_uid_1"
61+
expect(metadata.content_type_uid).to eq 'sys_assets'
62+
expect(metadata.text).to eq ''
63+
end
64+
65+
it 'Entry Block Json To metadata' do
66+
doc = getJson(EntryReferenceBlockJson)
67+
metadata = ContentstackUtils::Model::Metadata.new(doc["children"][0])
68+
expect(metadata.item_type).to eq "entry"
69+
expect(metadata.style_type).to eq "block"
70+
expect(metadata.item_uid).to eq "entry_uid_1"
71+
expect(metadata.content_type_uid).to eq 'content_block'
72+
expect(metadata.text).to eq ''
73+
end
74+
75+
it 'Entry Link Json To metadata' do
76+
doc = getJson(EntryReferenceLinkJson)
77+
metadata = ContentstackUtils::Model::Metadata.new(doc["children"][0])
78+
expect(metadata.item_type).to eq "entry"
79+
expect(metadata.style_type).to eq "link"
80+
expect(metadata.item_uid).to eq "entry_uid_2"
81+
expect(metadata.content_type_uid).to eq 'embeddedrte'
82+
expect(metadata.text).to eq "/copy-of-entry-final-02"
83+
end
84+
85+
it 'Entry Inline Json To metadata' do
86+
doc = getJson(EntryReferenceInlineJson)
87+
metadata = ContentstackUtils::Model::Metadata.new(doc["children"][0])
88+
expect(metadata.item_type).to eq "entry"
89+
expect(metadata.style_type).to eq "inline"
90+
expect(metadata.item_uid).to eq "entry_uid_3"
91+
expect(metadata.content_type_uid).to eq 'embeddedrte'
92+
expect(metadata.text).to eq ''
93+
end
94+
end
95+
end

0 commit comments

Comments
 (0)