File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -198,8 +198,7 @@ impl fmt::Display for ngx_str_t {
198
198
for chunk in self . as_bytes ( ) . utf8_chunks ( ) {
199
199
f. write_str ( chunk. valid ( ) ) ?;
200
200
for byte in chunk. invalid ( ) {
201
- f. write_str ( "\\ x" ) ?;
202
- fmt:: LowerHex :: fmt ( byte, f) ?;
201
+ write ! ( f, "\\ x{byte:02x}" ) ?;
203
202
}
204
203
}
205
204
Ok ( ( ) )
@@ -318,6 +317,7 @@ pub unsafe fn add_to_ngx_table(
318
317
#[ cfg( test) ]
319
318
mod tests {
320
319
extern crate alloc;
320
+ use alloc:: format;
321
321
use alloc:: string:: ToString ;
322
322
323
323
use super :: * ;
@@ -340,5 +340,14 @@ mod tests {
340
340
} ;
341
341
assert_eq ! ( str . to_string( ) , * expected) ;
342
342
}
343
+
344
+ // Check that the formatter arguments are ignored correctly
345
+ for ( bytes, expected) in & pairs[ 2 ..3 ] {
346
+ let str = ngx_str_t {
347
+ data : bytes. as_ptr ( ) . cast_mut ( ) ,
348
+ len : bytes. len ( ) ,
349
+ } ;
350
+ assert_eq ! ( format!( "{str:12.12}" ) , * expected) ;
351
+ }
343
352
}
344
353
}
You can’t perform that action at this time.
0 commit comments