Commit 430c3dd
committed
doc: correct unsafe URL example in http docs
Co-authored-by: @astlouisf
Co-authored-by: @samhh
The previous documentation example for converting `request.url` to an `URL` object was unsafe, as it could allow a server crash through malformed URL inputs and potentially enable host header attacks.
This commit revises the example to use string concatenation over the usage of the `baseUrl` and removes the usage of the `req.headers.host` as the authority part of the url, mitigating both the crash and security risks by ensuring the host part of the URL remains controlled and predictable.
Fixes #524941 parent 9ef03f1 commit 430c3dd
1 file changed
Lines changed: 7 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2886 | 2886 | | |
2887 | 2887 | | |
2888 | 2888 | | |
2889 | | - | |
| 2889 | + | |
2890 | 2890 | | |
2891 | 2891 | | |
2892 | | - | |
2893 | | - | |
| 2892 | + | |
2894 | 2893 | | |
2895 | 2894 | | |
2896 | 2895 | | |
2897 | | - | |
| 2896 | + | |
2898 | 2897 | | |
2899 | | - | |
2900 | | - | |
| 2898 | + | |
| 2899 | + | |
2901 | 2900 | | |
2902 | 2901 | | |
2903 | 2902 | | |
2904 | | - | |
| 2903 | + | |
2905 | 2904 | | |
2906 | | - | |
| 2905 | + | |
2907 | 2906 | | |
2908 | 2907 | | |
2909 | 2908 | | |
| |||
0 commit comments