@@ -236,12 +236,35 @@ def test_direct_setter_accepts_https_and_explicit_local_http_ranges(self, config
236236 "http://local\n host/v1" ,
237237 "https://user:password@example.com/v1" ,
238238 "https://example.com:99999/v1" ,
239+ "https://0177.0.0.1/v1" ,
240+ "https://127.000.000.001/v1" ,
241+ "https://999.1.1.1/v1" ,
242+ "https://api.example.com/\x7f " ,
243+ "https://api.example.com/\u0080 " ,
239244 ],
240245 )
241246 def test_direct_setter_rejects_unsafe_or_malformed_urls (self , config , value ):
242247 with pytest .raises (ValueError , match = "LLM base URL" ):
243248 config .llm_base_url = value
244249
250+ @pytest .mark .parametrize (
251+ "unsafe_url" ,
252+ [
253+ "https://0177.0.0.1/v1" ,
254+ "https://999.1.1.1/v1" ,
255+ ],
256+ )
257+ def test_stored_noncanonical_numeric_https_url_is_cleared (self , config_dir , unsafe_url ):
258+ config_dir .mkdir (parents = True , exist_ok = True )
259+ (config_dir / "config.json" ).write_text (
260+ json .dumps ({"llm_base_url" : unsafe_url }), encoding = "utf-8"
261+ )
262+
263+ loaded = BlitztextConfig (config_dir = config_dir )
264+
265+ assert loaded .llm_base_url == ""
266+ assert loaded .has_unsafe_llm_base_url is True
267+
245268 def test_legacy_public_http_url_is_cleared_and_warned_without_echoing_url (self , config_dir , caplog ):
246269 config_dir .mkdir (parents = True , exist_ok = True )
247270 unsafe_url = "http://api.example.com/v1"
0 commit comments