Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Changed the cookie binder to check if the regex matches before pullin…
Browse files Browse the repository at this point in the history
…g the value out
  • Loading branch information
nathanpalmer committed Aug 20, 2012
1 parent 34a53ce commit 4d5260a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/spine.databind.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ class Cookie extends Template
keys: [ "cookie" ]

@get: (sKey) ->
unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"), "$1"))
regex = new RegExp("(?:^|.*;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*")
return unescape(document.cookie.replace(regex, "$1")) if regex.test(document.cookie)

@set: (sKey, sValue, vEnd, sPath, sDomain, bSecure) ->
return if not sKey or /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)
Expand All @@ -458,7 +459,7 @@ class Cookie extends Template
update: (operators,model,controller,el,options) ->
for operator in operators
value = @get(model,operator.property)
Cookie.set(operator.target,value)
Cookie.set(operator.target,value) if value and value isnt "undefined"

change: (operators,model,controller,el,options) ->
for operator in operators
Expand Down
12 changes: 10 additions & 2 deletions src/spine.databind.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4d5260a

Please sign in to comment.