git-diff icon indicating copy to clipboard operation
git-diff copied to clipboard

Diffs on strings with contents like $2 get improperly manged on gitDiff output

Open yahelc opened this issue 5 years ago • 2 comments

Strings of the pattern \$\d seem to be getting substituted out. This is resulting in simple dollar amounts being mangled. I imagine this could be due to some step where those values are being run through a step that results shell command substitution of values like $1, $2, etc.

EXAMPLE (run on [email protected]):

console.log( gitDiff("How about $2?\n","How 'bout $2?\n") )

EXPECTED RESULT:

@@ -1 +1 @@
-How about $2?
+How 'bout $2?

ACTUAL RESULT:

@@ -1 +1 @@
-How about ?
+How 'bout ?

yahelc avatar Apr 30 '20 15:04 yahelc

Not only $[number], any $[word] applied. For example $pull , MongoDB queries.

JoHuang avatar Jun 08 '22 17:06 JoHuang

var oldStr = '"price":"$0"\n';
var newStr = '"price":"1"\n';
var diff = gitDiff(oldStr, newStr);
console.log(diff);

outputs:

@@ -1 +1 @@
-"price":"/bin/sh"
+"price":"1"

artem-pdus avatar Apr 10 '23 21:04 artem-pdus