Skip to content

Commit

Permalink
[php2cpg] Try multiple charsets when reading file content (#5222)
Browse files Browse the repository at this point in the history
  • Loading branch information
johannescoetzee authored Jan 14, 2025
1 parent 277fc6c commit a922084
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name := "joern"
ThisBuild / organization := "io.joern"
ThisBuild / scalaVersion := "3.5.2"

val cpgVersion = "1.7.19"
val cpgVersion = "1.7.21"

lazy val joerncli = Projects.joerncli
lazy val querydb = Projects.querydb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import io.joern.x2cpg.{Ast, AstCreatorBase, AstNodeBuilder, Defines, ValidationM
import io.shiftleft.codepropertygraph.generated.*
import io.shiftleft.codepropertygraph.generated.nodes.*
import io.shiftleft.semanticcpg.language.types.structure.NamespaceTraversal
import io.shiftleft.utils.IOUtils
import org.slf4j.LoggerFactory

import java.nio.charset.StandardCharsets
import java.nio.file.{Files, Path}
import java.nio.file.Path
import scala.collection.mutable

class AstCreator(relativeFileName: String, fileName: String, phpAst: PhpFile, disableFileContent: Boolean)(implicit
Expand All @@ -35,7 +36,7 @@ class AstCreator(relativeFileName: String, fileName: String, phpAst: PhpFile, di

override def createAst(): DiffGraphBuilder = {
if (!disableFileContent) {
fileContent = Some(Files.readString(Path.of(fileName)))
fileContent = Option(IOUtils.readEntireFile(Path.of(fileName)))
}

val ast = astForPhpFile(phpAst)
Expand Down

0 comments on commit a922084

Please sign in to comment.