From b34a29d931b9626fd9f4cdcaf0186239049d5a72 Mon Sep 17 00:00:00 2001 From: isc-hwojnick Date: Mon, 8 Jul 2024 13:00:53 -0400 Subject: [PATCH 1/2] now allows ampersands in the commit message --- cls/SourceControl/Git/PullEventHandler.cls | 1 + .../Git/Util/ProductionConflictResolver.cls | 1 + cls/SourceControl/Git/Utils.cls | 1 + cls/SourceControl/Git/WebUIDriver.cls | 35 ++++++++++--------- .../share/git-webui/webui/js/git-webui.js | 2 +- .../src/share/git-webui/webui/js/git-webui.js | 2 +- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/cls/SourceControl/Git/PullEventHandler.cls b/cls/SourceControl/Git/PullEventHandler.cls index 66728728..3e3eb07b 100644 --- a/cls/SourceControl/Git/PullEventHandler.cls +++ b/cls/SourceControl/Git/PullEventHandler.cls @@ -45,3 +45,4 @@ ClassMethod ForInternalNames(InternalName As %String) As %Status } } + diff --git a/cls/SourceControl/Git/Util/ProductionConflictResolver.cls b/cls/SourceControl/Git/Util/ProductionConflictResolver.cls index ec29a1a9..57b7525f 100644 --- a/cls/SourceControl/Git/Util/ProductionConflictResolver.cls +++ b/cls/SourceControl/Git/Util/ProductionConflictResolver.cls @@ -154,3 +154,4 @@ ClassMethod ResolveStream(stream As %Stream.Object) } } + diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index e7977155..a017afdc 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -2464,3 +2464,4 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status } } + diff --git a/cls/SourceControl/Git/WebUIDriver.cls b/cls/SourceControl/Git/WebUIDriver.cls index 80c6ef37..1b5bd91f 100644 --- a/cls/SourceControl/Git/WebUIDriver.cls +++ b/cls/SourceControl/Git/WebUIDriver.cls @@ -89,25 +89,28 @@ 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) + #; for { + #; set reference = $query(@reference) + #; merge ^mtempref($i(^mtempref)) = 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 + #; } + #; } + #; } + // 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() @@ -117,7 +120,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) { diff --git a/git-webui/release/share/git-webui/webui/js/git-webui.js b/git-webui/release/share/git-webui/webui/js/git-webui.js index c2b7d568..36636040 100644 --- a/git-webui/release/share/git-webui/webui/js/git-webui.js +++ b/git-webui/release/share/git-webui/webui/js/git-webui.js @@ -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 = {}; diff --git a/git-webui/src/share/git-webui/webui/js/git-webui.js b/git-webui/src/share/git-webui/webui/js/git-webui.js index c2b7d568..36636040 100644 --- a/git-webui/src/share/git-webui/webui/js/git-webui.js +++ b/git-webui/src/share/git-webui/webui/js/git-webui.js @@ -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 = {}; From 4c62bad46ba50a3791e71e4d07fe4af9671693d5 Mon Sep 17 00:00:00 2001 From: isc-hwojnick Date: Mon, 8 Jul 2024 13:03:01 -0400 Subject: [PATCH 2/2] finished removing dead code --- CHANGELOG.md | 1 + cls/SourceControl/Git/WebUIDriver.cls | 12 ------------ 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 689bf6bf..fa75bd4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 `` 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 diff --git a/cls/SourceControl/Git/WebUIDriver.cls b/cls/SourceControl/Git/WebUIDriver.cls index 1b5bd91f..cb377232 100644 --- a/cls/SourceControl/Git/WebUIDriver.cls +++ b/cls/SourceControl/Git/WebUIDriver.cls @@ -91,18 +91,6 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out if (pathStart = "git") { merge data = %request.Data set args = data("command",1) - #; for { - #; set reference = $query(@reference) - #; merge ^mtempref($i(^mtempref)) = 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 - #; } - #; } - #; } - // Problem: args(1) might contain $c(10) followed by our stdin value if $data(args)#2 {