Skip to content

Commit

Permalink
fix: properly escape shell commands
Browse files Browse the repository at this point in the history
  • Loading branch information
123FLO321 committed Apr 27, 2022
1 parent 914d968 commit fd9619c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Vapor
import ShellOut

internal class DatasetsController {

Expand Down Expand Up @@ -99,15 +98,15 @@ internal class DatasetsController {
if datasets.count == 1 {
try? FileManager.default.removeItem(atPath: self.folder + "/Combined.mbtiles")
do {
try shellOut(to: "/bin/ln", arguments: ["-s", "List/\(datasets[0]).mbtiles".bashEncoded, "Combined.mbtiles"], at: self.folder)
try escapedShellOut(to: "/bin/ln", arguments: ["-s", "List/\(datasets[0]).mbtiles", "Combined.mbtiles"], at: self.folder)
} catch {
return request.eventLoop.makeFailedFuture("Failed to link mbtiles: \(error.localizedDescription)")
}
return request.eventLoop.future()
} else {
return request.application.threadPool.runIfActive(eventLoop: request.eventLoop) {
do {
try shellOut(to: DatasetsController.tileJoinCommand, arguments: ["--force", "-o", "Combined.mbtiles", "List/*.mbtiles".bashEncoded], at: self.folder)
try escapedShellOut(to: DatasetsController.tileJoinCommand, arguments: ["--force", "-o", "Combined.mbtiles", "List/*.mbtiles"], at: self.folder)
} catch {
throw Abort(.internalServerError, reason: "Failed to get mbtiles: \(error.localizedDescription)")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Vapor
import ShellOut

internal class FontsController {

Expand Down Expand Up @@ -63,7 +62,7 @@ internal class FontsController {
try? FileManager.default.removeItem(atPath: path)
do {
try FileManager.default.createDirectory(atPath: path, withIntermediateDirectories: false)
try shellOut(to: FontsController.buildGlyphsCommand, arguments: [file.bashEncoded, path.bashEncoded])
try escapedShellOut(to: FontsController.buildGlyphsCommand, arguments: [file, path])
} catch {
try? FileManager.default.removeItem(atPath: path)
throw Abort(.internalServerError, reason: "Failed to create glyphs: \(error.localizedDescription)")
Expand Down
Empty file.

0 comments on commit fd9619c

Please sign in to comment.