Repository: joernio/joern (scala)

Issue:
Strings containing escaped double quotes break graphviz graph generation
Hello!

If you have the following code:
```
void lemon(){
  goog("yes");
}
```

then when `cpg.method("lemon").plotDotAst` is run, a graph is generated. however this code
```
void lemon(){
  goog("\"yes\"");
}
```
leads to 
![image](https://user-images.githubusercontent.com/16514075/146416893-123541e0-0ae9-4afd-8acf-2b3b1480f6bb.png)

also, the following do not break the graph generation

* `goog("'yes'")` (single quotes within double quotes)
* `goog('"lemon"')` (double quotes within single quotes, yes invalid c)
* `goog('\'lemon\'')` (escaped single quotes within single quotes, invalid c)

This was last tested on release  v1.1.397

Pull request:
Also added tests.

Fixes: #830

Patch:
diff --git a/build.sbt b/build.sbt
index 5265e0efaec5..ef5a0b366141 100644
--- a/build.sbt
+++ b/build.sbt
@@ -2,8 +2,8 @@ name := "joern"
 ThisBuild / organization := "io.joern"
 ThisBuild / scalaVersion := "2.13.7"
 
-val cpgVersion = "1.3.466"
-val js2cpgVersion = "0.2.73"
+val cpgVersion = "1.3.472"
+val js2cpgVersion = "0.2.78"
 
 lazy val joerncli = Projects.joerncli
 lazy val querydb = Projects.querydb


Test patch:
diff --git a/joern-cli/frontends/c2cpg/src/test/scala/io/joern/c2cpg/dotgenerator/DotAstGeneratorTests.scala b/joern-cli/frontends/c2cpg/src/test/scala/io/joern/c2cpg/dotgenerator/DotAstGeneratorTests.scala
index d862d65da7d1..119bd4f5dcdd 100644
--- a/joern-cli/frontends/c2cpg/src/test/scala/io/joern/c2cpg/dotgenerator/DotAstGeneratorTests.scala
+++ b/joern-cli/frontends/c2cpg/src/test/scala/io/joern/c2cpg/dotgenerator/DotAstGeneratorTests.scala
@@ -21,6 +21,10 @@ class DotAstGeneratorTests extends CCodeToCpgSuite {
        |  printf("Boop!");
        |  return;
        |}
+       |
+       |void lemon(){
+       |  goog("\"yes\"");
+       |}
        |""".stripMargin
 
   "An AstDotGenerator" should {
@@ -55,5 +59,17 @@ class DotAstGeneratorTests extends CCodeToCpgSuite {
       }
     }
 
+    "allow plotting sub trees of methods correctly escaped" in {
+      inside(cpg.method.name("lemon").dotAst.l) {
+        case List(x) =>
+          x should (
+            startWith("digraph \"lemon\"") and
+              include("""[label = "(goog,goog(\"\\\"yes\\\"\"))" ]""") and
+              include("""[label = "(LITERAL,\"\\\"yes\\\"\",goog(\"\\\"yes\\\"\"))" ]""") and
+              endWith("}\n")
+          )
+      }
+    }
+
   }
 }
diff --git a/joern-cli/frontends/fuzzyc2cpg/src/test/scala/io/joern/fuzzyc2cpg/dotgenerator/DotAstGeneratorTests.scala b/joern-cli/frontends/fuzzyc2cpg/src/test/scala/io/joern/fuzzyc2cpg/dotgenerator/DotAstGeneratorTests.scala
index db5e9da924c8..4fe5307461ca 100644
--- a/joern-cli/frontends/fuzzyc2cpg/src/test/scala/io/joern/fuzzyc2cpg/dotgenerator/DotAstGeneratorTests.scala
+++ b/joern-cli/frontends/fuzzyc2cpg/src/test/scala/io/joern/fuzzyc2cpg/dotgenerator/DotAstGeneratorTests.scala
@@ -5,7 +5,7 @@ import io.shiftleft.semanticcpg.language._
 
 class DotAstGeneratorTests extends FuzzyCCodeToCpgSuite {
 
-  override val code =
+  override val code: String =
     """| // A comment
        |int my_func(int x)
        |{
@@ -21,6 +21,10 @@ class DotAstGeneratorTests extends FuzzyCCodeToCpgSuite {
        |  printf("Boop!");
        |  return;
        |}
+       |
+       |void lemon(){
+       |  goog("\"yes\"");
+       |}
        |""".stripMargin
 
   "An AstDotGenerator" should {
@@ -59,5 +63,18 @@ class DotAstGeneratorTests extends FuzzyCCodeToCpgSuite {
       }
     }
 
+    "allow plotting sub trees of methods correctly escaped" in {
+      cpg.method.name("lemon").dotAst.l match {
+        case x :: _ =>
+          x should (
+            startWith("digraph \"lemon\"") and
+              include("""[label = "(goog,goog(\"\\\"yes\\\"\"))" ]""") and
+              include("""[label = "(LITERAL,\"\\\"yes\\\"\",goog(\"\\\"yes\\\"\"))" ]""") and
+              endWith("}\n")
+          )
+        case _ => fail()
+      }
+    }
+
   }
 }