From 355d97a94db6363ba2084eff87ce5d7db2b635e6 Mon Sep 17 00:00:00 2001
From: Ali Spittel
Date: Wed, 20 Feb 2019 13:08:46 -0500
Subject: [PATCH] add sanitization to github on chat (#1834)
* add sanitization to github on chat
* formatting
---
app/javascript/chat/content.jsx | 109 ++++++++++++++----------
app/javascript/chat/githubRepo.jsx | 129 ++++++++++++++---------------
2 files changed, 130 insertions(+), 108 deletions(-)
diff --git a/app/javascript/chat/content.jsx b/app/javascript/chat/content.jsx
index a7dedafeb..c4e977cc8 100644
--- a/app/javascript/chat/content.jsx
+++ b/app/javascript/chat/content.jsx
@@ -12,60 +12,83 @@ export default class Content extends Component {
activeChannelId: PropTypes.number,
pusherKey: PropTypes.string,
};
+
render() {
+ console.log(this.props);
if (!this.props.resource) {
- return ""
- } else {
+ return '';
+ }
return (
+ >
- {display(this.props)}
+ >
+ ×
+
+ {display(this.props)}
);
- }
+
}
}
function display(props) {
- if (props.resource.type_of === "loading-user") {
- return
- } else if (props.resource.type_of === "loading-user") {
- return
- } else if (props.resource.type_of === "user") {
- return
- } else if (props.resource.type_of === "article") {
- return
- } else if (props.resource.type_of === "github") {
- return
- } else if (props.resource.type_of === "channel-details") {
- return
- } else if (props.resource.type_of === "code_editor") {
- return
+ if (props.resource.type_of === 'loading-user') {
+ return (
+
+ );
+ } if (props.resource.type_of === 'loading-user') {
+ return (
+
+ );
+ } if (props.resource.type_of === 'user') {
+ return ;
+ } if (props.resource.type_of === 'article') {
+ return ;
+ } if (props.resource.type_of === 'github') {
+ return (
+
+ );
+ } if (props.resource.type_of === 'channel-details') {
+ return (
+
+ );
+ } if (props.resource.type_of === 'code_editor') {
+ return (
+
+ );
}
-}
\ No newline at end of file
+}
diff --git a/app/javascript/chat/githubRepo.jsx b/app/javascript/chat/githubRepo.jsx
index d25a0d871..013a9c697 100644
--- a/app/javascript/chat/githubRepo.jsx
+++ b/app/javascript/chat/githubRepo.jsx
@@ -22,14 +22,14 @@ export default class GithubRepo extends Component {
getJSONContents(
`https://api.github.com/repos/${
this.props.resource.args
- }/contents?access_token=${ this.state.token}`,
+ }/contents?access_token=${this.state.token}`,
this.loadContent,
this.loadFailure,
);
getJSONContents(
`https://api.github.com/repos/${
this.props.resource.args
- }/readme?access_token=${ this.state.token}`,
+ }/readme?access_token=${this.state.token}`,
this.loadContent,
this.loadFailure,
);
@@ -40,7 +40,7 @@ export default class GithubRepo extends Component {
handleItemClick = e => {
e.preventDefault();
getJSONContents(
- `${e.target.dataset.apiUrl}&access_token=${ this.state.token}`,
+ `${e.target.dataset.apiUrl}&access_token=${this.state.token}`,
this.loadContent,
this.loadFailure,
);
@@ -102,7 +102,8 @@ export default class GithubRepo extends Component {
);
- } if (this.state.content) {
+ }
+ if (this.state.content) {
return (
@@ -111,68 +112,66 @@ export default class GithubRepo extends Component {
{this.state.content}
);
- }
- const directories = this.state.directories.map(item => (
-
- ));
- const files = this.state.files.map(item => (
-
- ));
- let readme = '';
- if (this.state.readme) {
- readme = (
-
- );
- }
- if (this.state.root) {
- return (
-
-
-
- {directories}
- {files}
-
- {readme}
+ }
+ const directories = this.state.directories.map(item => (
+
+ ));
+ const files = this.state.files.map(item => (
+
+ ));
+ let readme = '';
+ if (this.state.readme) {
+ readme = (
+
+ );
+ }
+ if (this.state.root) {
+ return (
+
+
- );
- }
- return (
-
-
- {this.state.path}
-
-
- {directories}
- {files}
-
+
+ {directories}
+ {files}
- );
-
-
+ {readme}
+
+ );
+ }
+ return (
+
+
{this.state.path}
+
+ {directories}
+ {files}
+
+
+ );
}
}