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 ...@@ -30,7 +30,7 @@ data PathResult = OkRelPath RelPath
-- | horrible regex parsing for filepaths that is hopefully kinda safe -- | horrible regex parsing for filepaths that is hopefully kinda safe
parsePath :: Text -> PathResult parsePath :: Text -> PathResult
parsePath text = parsePath text =
if | text =~ ("{{{.*}}}" :: Text) -> PathVarsDisallowed if | T.isInfixOf "{{" text || T.isInfixOf "}}" text -> PathVarsDisallowed
| rest =~ ("^([^/]*[^\\./]/)*[^/]*[^\\./]$" :: Text) -> OkRelPath (Path up path fragment) | rest =~ ("^([^/]*[^\\./]/)*[^/]*[^\\./]$" :: Text) -> OkRelPath (Path up path fragment)
| "/_/" `isPrefixOf` text -> UnderscoreMapLink | "/_/" `isPrefixOf` text -> UnderscoreMapLink
| "/@/" `isPrefixOf` text -> AtMapLink | "/@/" `isPrefixOf` text -> AtMapLink
......
...@@ -18,6 +18,7 @@ import Data.Either.Combinators (maybeToRight) ...@@ -18,6 +18,7 @@ import Data.Either.Combinators (maybeToRight)
import Data.Map.Strict (Map) import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import Data.Text (Text, pack) import Data.Text (Text, pack)
import qualified Data.Text as T
import GHC.Generics (Generic) import GHC.Generics (Generic)
import GHC.TypeLits (KnownSymbol, symbolVal) import GHC.TypeLits (KnownSymbol, symbolVal)
import Text.Regex.TDFA ((=~)) import Text.Regex.TDFA ((=~))
...@@ -66,7 +67,7 @@ data SubstError = ...@@ -66,7 +67,7 @@ data SubstError =
applySubst :: KnownSymbol s applySubst :: KnownSymbol s
=> Proxy s -> SchemaSet -> Text -> Either SubstError Text => Proxy s -> SchemaSet -> Text -> Either SubstError Text
applySubst s substs uri = do applySubst s substs uri = do
when (uri =~ "{{{.*}}}") when (T.isInfixOf (pack "{{") uri || T.isInfixOf (pack "}}") uri)
$ Left VarsDisallowed $ Left VarsDisallowed
(schema, domain, rest) <- note NotALink $ parseUri uri (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