Skip to content
Snippets Groups Projects
Commit 5970aaec authored by stuebinm's avatar stuebinm
Browse files

disallow double courly braces

as per yesterday's discussion about extended scripting variables
parent 3a9af932
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,7 @@ data PathResult = OkRelPath RelPath
-- | horrible regex parsing for filepaths that is hopefully kinda safe
parsePath :: Text -> PathResult
parsePath text =
if | text =~ ("{{{.*}}}" :: Text) -> PathVarsDisallowed
if | T.isInfixOf "{{" text || T.isInfixOf "}}" text -> PathVarsDisallowed
| rest =~ ("^([^/]*[^\\./]/)*[^/]*[^\\./]$" :: Text) -> OkRelPath (Path up path fragment)
| "/_/" `isPrefixOf` text -> UnderscoreMapLink
| "/@/" `isPrefixOf` text -> AtMapLink
......
......@@ -18,6 +18,7 @@ import Data.Either.Combinators (maybeToRight)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M
import Data.Text (Text, pack)
import qualified Data.Text as T
import GHC.Generics (Generic)
import GHC.TypeLits (KnownSymbol, symbolVal)
import Text.Regex.TDFA ((=~))
......@@ -66,7 +67,7 @@ data SubstError =
applySubst :: KnownSymbol s
=> Proxy s -> SchemaSet -> Text -> Either SubstError Text
applySubst s substs uri = do
when (uri =~ "{{{.*}}}")
when (T.isInfixOf (pack "{{") uri || T.isInfixOf (pack "}}") uri)
$ Left VarsDisallowed
(schema, domain, rest) <- note NotALink $ parseUri uri
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment