Skip to content

POST requests to /git now accept all types of characters in the request body #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- WebUI works properly for users with %Developer without needing to add further SQL privileges (#365)
- Fixed `<UNDEFINED>` error running Import All (#380)
- Discarding changes now recompiles - critical for productions and some other cases (#387)
- Special characters in WebUI git commands now result in the command being executed properly (#369)

## [2.3.1] - 2024-04-30

Expand Down
1 change: 1 addition & 0 deletions cls/SourceControl/Git/PullEventHandler.cls
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ ClassMethod ForInternalNames(InternalName As %String) As %Status
}

}

1 change: 1 addition & 0 deletions cls/SourceControl/Git/Util/ProductionConflictResolver.cls
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,4 @@ ClassMethod ResolveStream(stream As %Stream.Object)
}

}

1 change: 1 addition & 0 deletions cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -2464,3 +2464,4 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
}

}

23 changes: 7 additions & 16 deletions cls/SourceControl/Git/WebUIDriver.cls
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,16 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
SimpleHTTPRequestHandler.do_POST(self)
*/
if (pathStart = "git") {
set reference = "%request.Data"
for {
set reference = $query(@reference)
quit:reference=""
if $qsubscript(reference,3)="O" {
set args(@reference)=$qsubscript(reference,1)
if $data(%request.Data($qsubscript(reference,1),$qsubscript(reference,2)),argValue)#2 && (argValue '= "") {
set args(@reference)=args(@reference)_"="_argValue
}
}
}
merge data = %request.Data
set args = data("command",1)

// Problem: args(1) might contain $c(10) followed by our stdin value
if $data(args(1))#2 {
set stdin = $piece(args(1),$char(10),2,*)
set args(1) = $piece(args(1),$char(10))
if $data(args)#2 {
set stdin = $piece(args,$char(10),2,*)
set args = $piece(args,$char(10))
}
set readOnlyCommands = $listbuild("branch","tag","log","ls-files","ls-tree","show","status","diff")
set baseCommand = $Piece(args(1)," ")
set baseCommand = $Piece(args," ")

if $listfind(readOnlyCommands,baseCommand) {
do %session.Unlock()
Expand All @@ -117,7 +108,7 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out

// TODO: Don't be lazy! Implement shlex.split in ObjectScript.
// The below is just a little bit cheesy.
set argList = $listfromstring(args(1)," ")
set argList = $listfromstring(args," ")
set pointer = 0
set inQuotedString = 0
while $listnext(argList,pointer,arg) {
Expand Down
2 changes: 1 addition & 1 deletion git-webui/release/share/git-webui/webui/js/git-webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ webui.git = function(cmd, arg1, arg2, arg3, arg4) {
var warningCallback = arg4;
}

$.post("git", cmd, function(data, status, xhr) {
$.post("git", {command: cmd}, function(data, status, xhr) {
if (xhr.status == 200) {
// Convention : last lines are footer meta data like headers. An empty line marks the start if the footers
var footers = {};
Expand Down
2 changes: 1 addition & 1 deletion git-webui/src/share/git-webui/webui/js/git-webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ webui.git = function(cmd, arg1, arg2, arg3, arg4) {
var warningCallback = arg4;
}

$.post("git", cmd, function(data, status, xhr) {
$.post("git", {command: cmd}, function(data, status, xhr) {
if (xhr.status == 200) {
// Convention : last lines are footer meta data like headers. An empty line marks the start if the footers
var footers = {};
Expand Down
Loading