Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions src/components/terminal/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default class TerminalComponent {
scrollOnUserInput: true,
rows: options.rows || 24,
cols: options.cols || 80,
port: options.port || 8767,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure but this might create injection vulnerabilities ig. Also it should be passed as number or whatever is expected type of it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose is to let plugin developers start terminal sessions that connect to their own AXS instances. So yes, it's technically an injection vulnerability but intended

fontSize: terminalSettings.fontSize,
fontFamily: terminalSettings.fontFamily,
fontWeight: terminalSettings.fontWeight,
Expand Down Expand Up @@ -566,13 +567,16 @@ export default class TerminalComponent {
rows: this.terminal.rows,
};

const response = await fetch("http://localhost:8767/terminals", {
method: "POST",
headers: {
"Content-Type": "application/json",
const response = await fetch(
`http://localhost:${this.options.port}/terminals`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(requestBody),
},
body: JSON.stringify(requestBody),
});
);

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
Expand Down Expand Up @@ -604,7 +608,7 @@ export default class TerminalComponent {

this.pid = pid;

const wsUrl = `ws://localhost:8767/terminals/${pid}`;
const wsUrl = `ws://localhost:${this.options.port}/terminals/${pid}`;

this.websocket = new WebSocket(wsUrl);

Expand Down Expand Up @@ -658,13 +662,16 @@ export default class TerminalComponent {
if (!this.pid || !this.serverMode) return;

try {
await fetch(`http://localhost:8767/terminals/${this.pid}/resize`, {
method: "POST",
headers: {
"Content-Type": "application/json",
await fetch(
`http://localhost:${this.options.port}/terminals/${this.pid}/resize`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ cols, rows }),
},
body: JSON.stringify({ cols, rows }),
});
);
} catch (error) {
console.error("Failed to resize terminal:", error);
}
Expand Down Expand Up @@ -953,9 +960,12 @@ export default class TerminalComponent {

if (this.pid && this.serverMode) {
try {
await fetch(`http://localhost:8767/terminals/${this.pid}/terminate`, {
method: "POST",
});
await fetch(
`http://localhost:${this.options.port}/terminals/${this.pid}/terminate`,
{
method: "POST",
},
);
} catch (error) {
console.error("Failed to terminate terminal:", error);
}
Expand Down