Skip to content

Commit 8442648

Browse files
authored
Merge pull request #400 from intersystems/webui-character-escape
POST requests to /git now accept all types of characters in the request body
2 parents 45e006f + 4c62bad commit 8442648

File tree

7 files changed

+13
-18
lines changed

7 files changed

+13
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3535
- WebUI works properly for users with %Developer without needing to add further SQL privileges (#365)
3636
- Fixed `<UNDEFINED>` error running Import All (#380)
3737
- Discarding changes now recompiles - critical for productions and some other cases (#387)
38+
- Special characters in WebUI git commands now result in the command being executed properly (#369)
3839

3940
## [2.3.1] - 2024-04-30
4041

cls/SourceControl/Git/PullEventHandler.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ ClassMethod ForInternalNames(InternalName As %String) As %Status
4545
}
4646

4747
}
48+

cls/SourceControl/Git/Util/ProductionConflictResolver.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,4 @@ ClassMethod ResolveStream(stream As %Stream.Object)
154154
}
155155

156156
}
157+

cls/SourceControl/Git/Utils.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,3 +2536,4 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
25362536
}
25372537

25382538
}
2539+

cls/SourceControl/Git/WebUIDriver.cls

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,16 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
8989
SimpleHTTPRequestHandler.do_POST(self)
9090
*/
9191
if (pathStart = "git") {
92-
set reference = "%request.Data"
93-
for {
94-
set reference = $query(@reference)
95-
quit:reference=""
96-
if $qsubscript(reference,3)="O" {
97-
set args(@reference)=$qsubscript(reference,1)
98-
if $data(%request.Data($qsubscript(reference,1),$qsubscript(reference,2)),argValue)#2 && (argValue '= "") {
99-
set args(@reference)=args(@reference)_"="_argValue
100-
}
101-
}
102-
}
92+
merge data = %request.Data
93+
set args = data("command",1)
10394

10495
// Problem: args(1) might contain $c(10) followed by our stdin value
105-
if $data(args(1))#2 {
106-
set stdin = $piece(args(1),$char(10),2,*)
107-
set args(1) = $piece(args(1),$char(10))
96+
if $data(args)#2 {
97+
set stdin = $piece(args,$char(10),2,*)
98+
set args = $piece(args,$char(10))
10899
}
109100
set readOnlyCommands = $listbuild("branch","tag","log","ls-files","ls-tree","show","status","diff")
110-
set baseCommand = $Piece(args(1)," ")
101+
set baseCommand = $Piece(args," ")
111102

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

118109
// TODO: Don't be lazy! Implement shlex.split in ObjectScript.
119110
// The below is just a little bit cheesy.
120-
set argList = $listfromstring(args(1)," ")
111+
set argList = $listfromstring(args," ")
121112
set pointer = 0
122113
set inQuotedString = 0
123114
while $listnext(argList,pointer,arg) {

git-webui/release/share/git-webui/webui/js/git-webui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ webui.git = function(cmd, arg1, arg2, arg3, arg4) {
119119
var warningCallback = arg4;
120120
}
121121

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

git-webui/src/share/git-webui/webui/js/git-webui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ webui.git = function(cmd, arg1, arg2, arg3, arg4) {
119119
var warningCallback = arg4;
120120
}
121121

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

0 commit comments

Comments
 (0)