Skip to content

Commit cdf2e4c

Browse files
committed
Remove Pastebin integration due to security concerns
This commit removes the functionality to get and upload code and workspace from Pastebin from the src/index.html and src/index.js files. This change is due to identified security breaches associated with Pastebin integration.
1 parent 736256a commit cdf2e4c

File tree

2 files changed

+42
-11
lines changed

2 files changed

+42
-11
lines changed

src/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
<body>
88
<div id="pageContainer">
99
<div id="outputPane">
10-
<pre id="generatedCode" style="min-height: 600px;"><code class="language-lua"></code></pre>
10+
<pre id="generatedCode" style="min-height: 50%;"><code class="language-lua"></code></pre>
1111
<input type="text" name="fileName" id="fileName" value="program">
1212
<button id="downloadButton">Download</button>
13+
<button id="loadButton">Load</button>
14+
<!--<button id="connectButton">Connect to Pastebin</button>
1315
<button id="uploadButton">Upload to Pastebin</button>
14-
<button id="conectButton">Connect to Pastebin</button>
1516
<button id="uploadWorkspaceButton">Upload Workspace to Pastebin</button>
16-
<button id="loadWorkspaceButton">Load Workspace from Pastebin</button>
17-
<button id="loadButton">Load</button>
17+
<button id="loadWorkspaceButton">Load Workspace from Pastebin</button>-->
1818
</div>
1919
<div id="blocklyDiv"></div>
2020
</div>

src/index.js

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,11 @@ const uploadToPastebin = () => {
8484
a.click();
8585
}
8686
};
87-
88-
xhr.send(`api_dev_key=nSfNmQEF3ttNwx-zjU5MvguXnz8Oruw7&api_user_key=${secret['api_user_key']}&api_folder_key=5BbL8uf5&api_option=paste&api_paste_code=${encodeURIComponent(code)}&api_paste_private=1&api_paste_name=${(fileName.value || 'workspace') + ' | lua (' + Math.random().toString(36).substring(7) + ')'}&api_paste_format=lua`);
87+
if (secret['connected'] === false) {
88+
xhr.send(`api_dev_key=nSfNmQEF3ttNwx-zjU5MvguXnz8Oruw7&api_user_key=${secret['api_user_key']}&api_folder_key=5BbL8uf5&api_option=paste&api_paste_code=${encodeURIComponent(code)}&api_paste_private=1&api_paste_name=${(fileName.value || 'workspace') + ' | lua (' + Math.random().toString(36).substring(7) + ')'}&api_paste_format=lua`);
89+
} else {
90+
xhr.send(`api_dev_key=nSfNmQEF3ttNwx-zjU5MvguXnz8Oruw7&api_option=paste&api_paste_code=${encodeURIComponent(code)}&api_paste_private=1&api_paste_name=${(fileName.value || 'workspace') + ' | lua (' + Math.random().toString(36).substring(7) + ')'}&api_paste_format=lua`);
91+
}
8992
}
9093

9194
const uploadWorkspaceToPastebin = () => {
@@ -102,7 +105,11 @@ const uploadWorkspaceToPastebin = () => {
102105
a.click();
103106
}
104107
};
105-
xhr.send(`api_dev_key=nSfNmQEF3ttNwx-zjU5MvguXnz8Oruw7&api_user_key=d43a286490fa94b7d413dd2f5eb8d38d&api_folder_key=5BbL8uf5&api_option=paste&api_paste_code=${encodeURIComponent(workspace)}&api_paste_private=1&api_paste_name=${(fileName.value || 'workspace') + ' | workspace (' + Math.random().toString(36).substring(7) + ')'}&api_paste_format=json`);
108+
if (secret['connected'] === false) {
109+
xhr.send(`api_dev_key=nSfNmQEF3ttNwx-zjU5MvguXnz8Oruw7&api_user_key=${secret['api_user_key']}&api_folder_key=5BbL8uf5&api_option=paste&api_paste_code=${encodeURIComponent(workspace)}&api_paste_private=1&api_paste_name=${(fileName.value || 'workspace') + ' | workspace (' + Math.random().toString(36).substring(7) + ')'}&api_paste_format=json`);
110+
} else {
111+
xhr.send(`api_dev_key=nSfNmQEF3ttNwx-zjU5MvguXnz8Oruw7&api_option=paste&api_paste_code=${encodeURIComponent(workspace)}&api_paste_private=1&api_paste_name=${(fileName.value || 'workspace') + ' | workspace (' + Math.random().toString(36).substring(7) + ')'}&api_paste_format=json`);
112+
}
106113
}
107114

108115
const loadWorkspaceFromPastebin = () => {
@@ -119,8 +126,32 @@ const loadWorkspaceFromPastebin = () => {
119126
xhr.send();
120127
}
121128

129+
//const connectToPastebin = () => {
130+
// const username = prompt('Enter pastebin username');
131+
// const password = prompt('Enter pastebin password');
132+
// const xhr = new XMLHttpRequest();
133+
// xhr.open('POST', 'https://pastebin.com/api/api_login.php', true);
134+
// xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
135+
// xhr.onreadystatechange = () => {
136+
// if (xhr.readyState == 4 && xhr.status == 200) {
137+
// const response = xhr.responseText;
138+
// if (response.startsWith('Bad API request')) {
139+
// alert('Invalid username or password');
140+
// } else {
141+
// secret['api_user_key'] = response;
142+
// alert('Connected to pastebin');
143+
// connectButton.disabled = true;
144+
// connectButton.innerText = 'Connected';
145+
// }
146+
// }
147+
// };
148+
// xhr.send(`api_dev_key=nSfNmQEF3ttNwx-zjU5MvguXnz8Oruw7&api_user_name=${username}&api_user_password=${password}`);
149+
//}
150+
151+
122152
downloadButton.onclick = downloadWorkspace;
123-
uploadButton.onclick = uploadToPastebin;
124-
uploadWorkspaceButton.onclick = uploadWorkspaceToPastebin;
125-
loadWorkspaceButton.onclick = loadWorkspaceFromPastebin;
126-
loadButton.onclick = loadWorkspace;
153+
loadButton.onclick = loadWorkspace;
154+
//connectButton.onclick = connectToPastebin;
155+
//uploadButton.onclick = uploadToPastebin;
156+
//uploadWorkspaceButton.onclick = uploadWorkspaceToPastebin;
157+
//loadWorkspaceButton.onclick = loadWorkspaceFromPastebin;

0 commit comments

Comments
 (0)