Commit 51f0151
committed
Fix explicit null value handling in compat mode
Follow-up to GH-2150.
`container.lookup` used `result != null` which caused explicit null values to
fall through to parent contexts. This was inconsistent with expected behavior
and with Mustache, which stops and returns a key when present in the object,
regardless of its value. The whole point of `compat` mode is to match Mustache's
lookup semantics, so I don't think this behavior was intended.
There were no tests for `compat` with an explicit null value, apart from a
couple `compat` + `strict` mode tests I just added myself in GH-2150.
One of these tests ("should still perform recursive lookup with a multi-part
path not in context") was inconsistent with the test immediately below it
("should directly return an explicitly null property"), and that is fixed here.
This change makes it possible for unify the lookup logic in `container.lookup`
and `container.strictLookup`, additionally fixing an issue where `strictLookup`
didn't respect the `allowedProtoMethods` runtime option the same as `lookup`
(see the added test in `spec/security.js` compared to the test above it).1 parent 3105ca7 commit 51f0151
4 files changed
Lines changed: 33 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
134 | 124 | | |
135 | 125 | | |
136 | 126 | | |
| |||
153 | 143 | | |
154 | 144 | | |
155 | 145 | | |
156 | | - | |
157 | | - | |
158 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
159 | 157 | | |
160 | 158 | | |
161 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
262 | 269 | | |
263 | 270 | | |
264 | 271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
305 | 315 | | |
306 | 316 | | |
307 | 317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
| 169 | + | |
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| |||
0 commit comments