Skip to content

Commit

Permalink
Sanitize Brand inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
ciukstar committed Nov 10, 2023
1 parent da13be9 commit ccd7df7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
6 changes: 3 additions & 3 deletions config/models.persistentmodels
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ Brand
markMime Text Maybe
markWidth Text Maybe
markHeight Text Maybe
name Textarea Maybe
strapline Textarea Maybe
name Html Maybe
strapline Html Maybe
ico ByteString Maybe
icoMime Text Maybe
more Textarea Maybe
more Html Maybe

ContactUs
business BusinessId OnDeleteCascade
Expand Down
9 changes: 4 additions & 5 deletions src/Admin/Business.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ import Yesod.Core
, redirect, addMessageI, newIdent, addScriptRemote, addStylesheetRemote
, FileInfo (fileContentType), TypedContent (TypedContent), typeSvg
, emptyContent, ToContent (toContent), fileSourceByteString
, preEscapedToMarkup
)
import Yesod.Core.Handler
( setUltDestCurrent, getCurrentRoute, getYesod, languages
Expand All @@ -89,7 +88,7 @@ import Yesod.Core.Widget (setTitleI, whamlet, toWidget)
import Yesod.Form.Input (runInputGet, iopt)
import Yesod.Form.Fields
( textField, emailField, textareaField, intField, dayField, timeField
, hiddenField, htmlField, checkBoxField, doubleField, unTextarea, fileField
, hiddenField, htmlField, checkBoxField, doubleField, fileField
)
import Yesod.Form.Functions
( generateFormPost, mreq, mopt, runFormPost, checkM, check )
Expand Down Expand Up @@ -316,12 +315,12 @@ formBrand bid brand extra = do
, fsTooltip = Nothing, fsId = Nothing, fsName = Nothing
, fsAttrs = [("class","mdc-text-field__input")]
} (brandMarkHeight . entityVal <$> brand)
(nameR,nameV) <- mopt textareaField FieldSettings
(nameR,nameV) <- mopt htmlField FieldSettings
{ fsLabel = SomeMessage MsgBrandName
, fsTooltip = Nothing, fsId = Nothing, fsName = Nothing
, fsAttrs = [("class","mdc-text-field__input")]
} (brandName . entityVal <$> brand)
(strapR,strapV) <- mopt textareaField FieldSettings
(strapR,strapV) <- mopt htmlField FieldSettings
{ fsLabel = SomeMessage MsgBrandStrapline
, fsTooltip = Nothing, fsId = Nothing, fsName = Nothing
, fsAttrs = [("class","mdc-text-field__input")]
Expand All @@ -331,7 +330,7 @@ formBrand bid brand extra = do
, fsTooltip = Nothing, fsId = Nothing, fsName = Nothing
, fsAttrs = [("style","display:none"),("accept","image/ico,.ico")]
} Nothing
(moreR,moreV) <- mopt textareaField FieldSettings
(moreR,moreV) <- mopt htmlField FieldSettings
{ fsLabel = SomeMessage MsgMore
, fsTooltip = Nothing, fsId = Nothing, fsName = Nothing
, fsAttrs = [("class","mdc-text-field__input")]
Expand Down
4 changes: 2 additions & 2 deletions src/Handler/Home.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import Text.Hamlet (Html)
import Settings (widgetFile)
import Yesod.Core
( Yesod(defaultLayout), setTitleI, setUltDestCurrent
, getMessages, preEscapedToMarkup
, getMessages
)
import Yesod.Auth (Route(LoginR), maybeAuth)
import Yesod.Form.Fields (unTextarea)

import Settings.StaticFiles (img_salon_svg)

import Database.Persist (Entity (Entity))
Expand Down
10 changes: 5 additions & 5 deletions templates/admin/business/brand/brand.hamlet
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,18 @@
<img src=@{AdminR $ BrandMarkR bid rid} alt=_{MsgBrandMark} style="max-width:100%">
<figcaption>
$maybe name <- name
#{preEscapedToMarkup $ unTextarea name}
^{name}
$maybe strap <- strap
#{preEscapedToMarkup $ unTextarea strap}
^{strap}
$nothing
<figure>
<figcaption>
$maybe name <- name
#{preEscapedToMarkup $ unTextarea name}
^{name}
$maybe strap <- strap
#{preEscapedToMarkup $ unTextarea strap}
^{strap}
$maybe more <- more
#{preEscapedToMarkup $ unTextarea more}
^{more}
$nothing
<figure style="text-align:center">
<span style="font-size:5rem;color:var(--mdc-theme-primary)">&varnothing;
Expand Down
10 changes: 5 additions & 5 deletions templates/homepage.hamlet
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@
<img src=@{AdminR $ BrandMarkR bid rid} alt=_{MsgBrandMark} style="max-width:100%">
<figcaption>
$maybe name <- name
#{preEscapedToMarkup $ unTextarea name}
^{name}
$maybe strap <- strap
#{preEscapedToMarkup $ unTextarea strap}
^{strap}
$nothing
<figure>
<figcaption>
$maybe name <- name
#{preEscapedToMarkup $ unTextarea name}
^{name}
$maybe strap <- strap
#{preEscapedToMarkup $ unTextarea strap}
^{strap}
$maybe more <- more
#{preEscapedToMarkup $ unTextarea more}
^{more}
$nothing
<div #brandDefault>
<figure>
Expand Down

0 comments on commit ccd7df7

Please sign in to comment.