@@ -30,6 +30,7 @@ import Data.Text (Text)
3030import qualified Data.Text as T
3131
3232import Sanctify.AST
33+ import Sanctify.WordPress.Constraints (isWpdbObject )
3334
3435-- | Context for output escaping
3536data EscapeContext
@@ -255,16 +256,16 @@ transformModernizeCrypto file = file { phpStatements = map (mapStatement moderni
255256
256257 modernizeNode loc@ (Located pos expr@ (ExprCall callee args)) =
257258 case functionName callee of
258- Just fn | fn == " rand" -> Located pos $ ExprCall (makeConst " random_int" ) (map updateArg args)
259- | fn == " md5" -> Located pos $ ExprCall (makeConst " hash" ) (Argument Nothing (Located pos $ ExprLiteral $ LitString " sha3-256" ) False : map updateArg args)
260- | fn == " sha1" -> Located pos $ ExprCall (makeConst " sodium_crypto_generichash" ) (map updateArg args)
259+ Just fn | fn == " rand" -> Located pos $ ExprCall (makeConst pos " random_int" ) (map updateArg args)
260+ | fn == " md5" -> Located pos $ ExprCall (makeConst pos " hash" ) (Argument Nothing (Located pos $ ExprLiteral $ LitString " sha3-256" ) False : map updateArg args)
261+ | fn == " sha1" -> Located pos $ ExprCall (makeConst pos " sodium_crypto_generichash" ) (map updateArg args)
261262 _ -> loc
262263
263264 modernizeNode loc = loc
264265
265266 updateArg (Argument name value unpack) = Argument name (modernizeExpr value) unpack
266267
267- makeConst name = Located pos $ ExprConstant $ QualifiedName [Name name] False
268+ makeConst p name = Located p $ ExprConstant $ QualifiedName [Name name] False
268269
269270 functionName (Located _ (ExprConstant (QualifiedName parts _))) = Just $ unName $ last parts
270271 functionName _ = Nothing
@@ -324,7 +325,7 @@ mapStatement f (Located pos stmt) = Located pos (case stmt of
324325 StmtContinue n -> StmtContinue n
325326 StmtEcho exprs -> StmtEcho (map f exprs)
326327 StmtGlobal vars -> StmtGlobal vars
327- StmtStatic pairs -> StmtStatic (map (ib -> (fst fib , fmap f ( snd fib) )) pairs)
328+ StmtStatic pairs -> StmtStatic (map (\ (var, mexpr) -> (var , fmap f mexpr )) pairs)
328329 StmtUnset exprs -> StmtUnset (map f exprs)
329330 StmtDeclare decls body -> StmtDeclare decls (map (mapStatement f) body)
330331 StmtNoop -> StmtNoop )
0 commit comments