Skip to content

Commit d8eb167

Browse files
Merge pull request #167 from NearSocial/release-2.5.5
## 2.5.5 - FIX: Restrict attributes of `Files` component to a whitelist. Reported by BrunoModificato from OtterSec.
2 parents e9e6173 + d44aad3 commit d8eb167

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 2.5.5
4+
5+
- FIX: Restrict attributes of `Files` component to a whitelist. Reported by BrunoModificato from OtterSec.
6+
37
## 2.5.4
48

59
- Added optional `commitModalBypass` feature config. When the `<CommitButton />` component is used inside of a widget with a matching `src` prop, the `CommitModal` will be bypassed and `onCommit()` will be called instantly when the button is clicked. If for some reason the requested transaction is invalid, the `CommitModal` will still appear to show an error message to the user. View example below to see configuration options.

dist/index.js

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": "near-social-vm",
3-
"version": "2.5.4",
3+
"version": "2.5.5",
44
"description": "Near Social VM",
55
"main": "dist/index.js",
66
"files": [

src/lib/vm/vm.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,31 @@ const requirePattern = (id) => {
413413
}
414414
};
415415

416+
const FilesComponentWhitelist = [
417+
"key",
418+
"name",
419+
"className",
420+
"onChange",
421+
"onError",
422+
"accepts",
423+
"multiple",
424+
"clickable",
425+
"maxFiles",
426+
"maxFileSize",
427+
"minFileSize",
428+
"dragActiveClassName",
429+
];
430+
431+
const filterFilesAttributes = (attributes) => {
432+
const filteredAttributes = {};
433+
FilesComponentWhitelist.forEach((key) => {
434+
if (attributes.hasOwnProperty(key)) {
435+
filteredAttributes[key] = attributes[key];
436+
}
437+
});
438+
return filteredAttributes;
439+
};
440+
416441
class Stack {
417442
constructor(prevStack, state) {
418443
this.prevStack = prevStack;
@@ -688,7 +713,7 @@ class VmStack {
688713
accepts={["image/*"]}
689714
minFileSize={1}
690715
clickable
691-
{...attributes}
716+
{...filterFilesAttributes(attributes)}
692717
>
693718
{status.img?.uploading ? (
694719
<>{Loading} Uploading</>
@@ -701,7 +726,7 @@ class VmStack {
701726
</div>
702727
);
703728
} else if (element === "Files") {
704-
return <Files {...attributes}>{children}</Files>;
729+
return <Files {...filterFilesAttributes(attributes)}>{children}</Files>;
705730
} else if (element === "iframe") {
706731
return <SecureIframe {...attributes} />;
707732
} else if (element === "Web3Connect") {

0 commit comments

Comments
 (0)