File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -5440,17 +5440,30 @@ inline bool parse_accept_header(const std::string &s,
5440
5440
return ;
5441
5441
}
5442
5442
5443
- try {
5444
- accept_entry.quality = std::stod (quality_str);
5445
- // Check if quality is in valid range [0.0, 1.0]
5446
- if (accept_entry.quality < 0.0 || accept_entry.quality > 1.0 ) {
5443
+ #ifdef CPPHTTPLIB_NO_EXCEPTIONS
5444
+ {
5445
+ std::istringstream iss (quality_str);
5446
+ iss >> accept_entry.quality ;
5447
+
5448
+ // Check if conversion was successful and entire string was consumed
5449
+ if (iss.fail () || !iss.eof ()) {
5447
5450
has_invalid_entry = true ;
5448
5451
return ;
5449
5452
}
5453
+ }
5454
+ #else
5455
+ try {
5456
+ accept_entry.quality = std::stod (quality_str);
5450
5457
} catch (...) {
5451
5458
has_invalid_entry = true ;
5452
5459
return ;
5453
5460
}
5461
+ #endif
5462
+ // Check if quality is in valid range [0.0, 1.0]
5463
+ if (accept_entry.quality < 0.0 || accept_entry.quality > 1.0 ) {
5464
+ has_invalid_entry = true ;
5465
+ return ;
5466
+ }
5454
5467
} else {
5455
5468
// No quality parameter, use entire entry as media type
5456
5469
accept_entry.media_type = entry;
You can’t perform that action at this time.
0 commit comments