| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 04a886c commit 45b55dc
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -344,7 +344,13 @@ void BindingData::Format(const FunctionCallbackInfo<Value>& args) { | |||
| 344 | 344 | // directly want to manipulate the url components without using the respective | |
| 345 | 345 | // setters. therefore we are using ada::url here. | |
| 346 | 346 | auto out = ada::parse<ada::url>(href.ToStringView()); | |
| 347 | - CHECK(out); | ||
| 347 | + if (!out) { | ||
| 348 | + // If the href cannot be re-parsed (e.g. due to ada parser inconsistencies | ||
| 349 | + // with certain IDN hostnames), return the original href unmodified rather | ||
| 350 | + // than crashing. | ||
| 351 | + args.GetReturnValue().Set(args[0]); | ||
| 352 | + return; | ||
| 353 | + } | ||
| 348 | 354 | ||
| 349 | 355 | if (!hash) { | |
| 350 | 356 | out->hash = std::nullopt; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -147,3 +147,11 @@ test('should format tel: prefix', { skip: !hasIntl }, () => { | |||
| 147 | 147 | url.format(new URL('tel:123'), { unicode: true }) | |
| 148 | 148 | ); | |
| 149 | 149 | }); | |
| 150 | + | ||
| 151 | + // Regression test: url.format should not crash on URLs that ada::url_aggregator | ||
| 152 | + // can parse but ada::url cannot (e.g. special scheme URLs with opaque paths). | ||
| 153 | + test('should not crash on URLs with invalid IDN hostnames', () => { | ||
| 154 | + const u = new URL('ws:xn-\u022B'); | ||
| 155 | + // doesNotThrow | ||
| 156 | + url.format(u, { fragment: false, unicode: false, auth: false, search: false }); | ||
| 157 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments