Skip to content

Commit a2def12

Browse files
Jiaming Youmeta-codesync[bot]
authored andcommitted
Fixed null.split(':') crashes
Summary: _extractHostFromHttpHost('') or _extractHostFromHttpHost(null) returns null (line 281-283), then _computeETLDPlus1ForHost calls _isIPAddress(null) → _isIPv6Address(null) → null.split(':') crashes. The minimal fix is to bail out of _computeETLDPlus1ForHost when hostname is falsy. Downstream CookieSettings already accepts a null domain (cookie just won't have one), and processRequest resets etld_plus_1 = null at the top, so leaving it null is consistent. My current fix (option A) — early-return in _computeETLDPlus1ForHost: ✅ Targeted, clear intent at the call site where the null actually originates ✅ Avoids a latent precedence bug at line 255 (more on this below) ❌ Doesn't protect other future callers of _isIPv6Address / _isIPAddress ___ overriding_review_checks_triggers_an_audit_and_retroactive_review Oncall Short Name: advertiser_experience_foundations Differential Revision: D104759549 fbshipit-source-id: 349b7edba71c1e082359e0530feec30fd73db1a9
1 parent 044e2a3 commit a2def12

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

nodejs/capi-param-builder/src/ParamBuilder.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ class ParamBuilder {
246246
// in case a new host is passed in for the same request
247247
this.host = host;
248248
const hostname = this._extractHostFromHttpHost(host);
249+
if (!hostname) {
250+
this.etld_plus_1 = null;
251+
this.sub_domain_index = 0;
252+
return;
253+
}
249254
if (this._isIPAddress(hostname)) {
250255
this.etld_plus_1 = this._maybeBracketIPv6(hostname);
251256
this.sub_domain_index = 0;

0 commit comments

Comments
 (0)