storeEmptyValues writes a key with JavaScript syntax in it where a snippet concatenates the cookie name. Seen on #23, at 4e99d36.
What happens
Session storage gains fod_data_51D_Bandwidth" + ". The key should be fod_data_51D_Bandwidth, the extracted name being 51D_Bandwidth. No correctly named key is written, so bandwidth never gets the empty placeholder this code exists to provide.
Since 4e99d36 moved the storeEmptyValues(body) call out of {{^_enableCookies}}, this happens in both cookie modes. Confirmed in a browser on the cookies-on GettingStarted-Web example and the cookies-off pmp-web demo.
Cause
valueSetPrefix captures the name in group 3, whose class admits quotes, whitespace and +:
That is right for the rewrite, which splices $3 back inside a string literal, so window.sessionStorage["fod_data_51D_Bandwidth" + ""] still evaluates to the correct key. It is wrong for storeEmptyValues, which uses the same capture as a literal name:
let valueName = found[3] || found[6];
window.sessionStorage[session51DataPrefix + valueName] = "";
Impact
getFodSavedValues() sweeps the _data_ prefix and buildBody() puts every result in the request body, in both modes since 4e99d36. So the server gets 51D_Bandwidth%22%20%2B%20%22= with an empty value on every request, and bandwidth still hangs where its snippet stores nothing.
Test coverage
tests/template-tests.js only ever uses "51D_name=" + value - line 366 and line 1366 - which keeps group 3 clean, so the defect cannot appear. Please cover every shape the cloud actually serves, asserting the extracted name in each case.
Must extract cleanly:
| Snippet |
Expected name |
document.cookie = "51D_ProfileIds=" + profileIds.join("|") |
51D_ProfileIds |
document.cookie = "51D_ScreenPixelsHeight=" + screen.height |
51D_ScreenPixelsHeight |
document.cookie = "51D_ThirdPartyCookiesEnabled=" + resultValue |
51D_ThirdPartyCookiesEnabled |
document.cookie=`51D_GetHighEntropyValues=${btoa(JSON.stringify(t))}` |
51D_GetHighEntropyValues |
document.cookie="51D_IsVerifiediPhone="+"True" |
51D_IsVerifiediPhone |
Currently broken, and the point of the issue:
| Snippet |
Currently extracts |
Expected |
document.cookie = "51D_Bandwidth" + "=" + encodeURIComponent(value) |
51D_Bandwidth" + " |
51D_Bandwidth |
document.cookie = "51D_Pos_" + key + "=" + pos.coords[key] |
51D_Pos_" + key + " |
no placeholder - the name is built at run time and cannot be known statically |
Worth asserting too that every key written under the _data_ prefix matches ^[A-Za-z0-9_]+$, so any future snippet shape that breaks extraction fails loudly rather than reaching the wire.
Suggested fix
Restrict the name to [A-Za-z0-9_]+ and add an explicit alternative for the "NAME" + "=" + form, so bandwidth extracts correctly and a run-time name stops matching and gets no placeholder rather than a wrong one.
storeEmptyValueswrites a key with JavaScript syntax in it where a snippet concatenates the cookie name. Seen on #23, at4e99d36.What happens
Session storage gains
fod_data_51D_Bandwidth" + ". The key should befod_data_51D_Bandwidth, the extracted name being51D_Bandwidth. No correctly named key is written, so bandwidth never gets the empty placeholder this code exists to provide.Since
4e99d36moved thestoreEmptyValues(body)call out of{{^_enableCookies}}, this happens in both cookie modes. Confirmed in a browser on the cookies-on GettingStarted-Web example and the cookies-off pmp-web demo.Cause
valueSetPrefixcaptures the name in group 3, whose class admits quotes, whitespace and+:That is right for the rewrite, which splices
$3back inside a string literal, sowindow.sessionStorage["fod_data_51D_Bandwidth" + ""]still evaluates to the correct key. It is wrong forstoreEmptyValues, which uses the same capture as a literal name:Impact
getFodSavedValues()sweeps the_data_prefix andbuildBody()puts every result in the request body, in both modes since4e99d36. So the server gets51D_Bandwidth%22%20%2B%20%22=with an empty value on every request, and bandwidth still hangs where its snippet stores nothing.Test coverage
tests/template-tests.jsonly ever uses"51D_name=" + value- line 366 and line 1366 - which keeps group 3 clean, so the defect cannot appear. Please cover every shape the cloud actually serves, asserting the extracted name in each case.Must extract cleanly:
document.cookie = "51D_ProfileIds=" + profileIds.join("|")51D_ProfileIdsdocument.cookie = "51D_ScreenPixelsHeight=" + screen.height51D_ScreenPixelsHeightdocument.cookie = "51D_ThirdPartyCookiesEnabled=" + resultValue51D_ThirdPartyCookiesEnableddocument.cookie=`51D_GetHighEntropyValues=${btoa(JSON.stringify(t))}`51D_GetHighEntropyValuesdocument.cookie="51D_IsVerifiediPhone="+"True"51D_IsVerifiediPhoneCurrently broken, and the point of the issue:
document.cookie = "51D_Bandwidth" + "=" + encodeURIComponent(value)51D_Bandwidth" + "51D_Bandwidthdocument.cookie = "51D_Pos_" + key + "=" + pos.coords[key]51D_Pos_" + key + "Worth asserting too that every key written under the
_data_prefix matches^[A-Za-z0-9_]+$, so any future snippet shape that breaks extraction fails loudly rather than reaching the wire.Suggested fix
Restrict the name to
[A-Za-z0-9_]+and add an explicit alternative for the"NAME" + "=" +form, so bandwidth extracts correctly and a run-time name stops matching and gets no placeholder rather than a wrong one.