@@ -1753,16 +1753,13 @@ lxb_url_parse_basic_h(lxb_url_parser_t *parser, lxb_url_t *url,
17531753 break ;
17541754 }
17551755
1756- if (pswd == NULL || !at_sign ) {
1757- tmp = (pswd != NULL ) ? pswd - 1 : p ;
1758-
1759- if (tmp > begin ) {
1760- status = lxb_url_percent_encode_after_utf_8 (begin , tmp ,
1761- & url -> username , url -> mraw ,
1762- LXB_URL_MAP_USERINFO , false);
1763- if (status != LXB_STATUS_OK ) {
1764- lxb_url_parse_return (orig_data , buf , status );
1765- }
1756+ tmp = (pswd != NULL ) ? pswd - 1 : p ;
1757+ if (tmp > begin ) {
1758+ status = lxb_url_percent_encode_after_utf_8 (begin , tmp ,
1759+ & url -> username , url -> mraw ,
1760+ LXB_URL_MAP_USERINFO , false);
1761+ if (status != LXB_STATUS_OK ) {
1762+ lxb_url_parse_return (orig_data , buf , status );
17661763 }
17671764 }
17681765
@@ -2343,6 +2340,17 @@ lxb_url_parse_basic_h(lxb_url_parser_t *parser, lxb_url_t *url,
23432340 lxb_url_parse_return (orig_data , buf , status );
23442341 }
23452342
2343+ /* Encode only the space immediately before a query or fragment. */
2344+ if (p > begin && p [-1 ] == ' ' ) {
2345+ tmp_str .length -- ;
2346+ if (lexbor_str_append (& tmp_str , url -> mraw ,
2347+ (const lxb_char_t * ) "%20" , 3 ) == NULL )
2348+ {
2349+ lxb_url_parse_return (orig_data , buf ,
2350+ LXB_STATUS_ERROR_MEMORY_ALLOCATION );
2351+ }
2352+ }
2353+
23462354 status = lxb_url_path_list_push (url , & tmp_str );
23472355 if (status != LXB_STATUS_OK ) {
23482356 lxb_url_parse_return (orig_data , buf , status );
@@ -4907,7 +4915,7 @@ lxb_status_t
49074915lxb_url_serialize_fragment (const lxb_url_t * url ,
49084916 lexbor_serialize_cb_f cb , void * ctx )
49094917{
4910- if (url -> query .data != NULL ) {
4918+ if (url -> fragment .data != NULL ) {
49114919 return cb (url -> fragment .data , url -> fragment .length , ctx );
49124920 }
49134921
@@ -5106,6 +5114,8 @@ lxb_url_search_params_parse(lxb_url_search_params_t *search_params,
51065114 return status ;
51075115 }
51085116
5117+ last = entry ;
5118+
51095119 lexbor_str_init (& entry -> value , mraw , 0 );
51105120 if (entry -> value .data == NULL ) {
51115121 return LXB_STATUS_ERROR_MEMORY_ALLOCATION ;
0 commit comments