Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
trying stringstream for double (stod)
  • Loading branch information
M4tteoP committed Aug 17, 2022
commit b02f7407b40cb4beabf360b1cc34827f16d04fe6
6 changes: 0 additions & 6 deletions .vscode/settings.json

This file was deleted.

13 changes: 7 additions & 6 deletions src/actions/rule_id.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <iostream>
#include <string>
#include <charconv>
#include <sstream>

#include "modsecurity/transaction.h"
#include "modsecurity/rule.h"
Expand All @@ -28,11 +28,12 @@ namespace actions {

bool RuleId::init(std::string *error) {
std::string a = m_parser_payload;

const auto format = std::chars_format::fixed;
const auto conv_res = std::from_chars(a.data(), a.data() + a.size(), m_ruleId, format);
if (conv_res.ec == std::errc::invalid_argument || conv_res.ec == std::errc::result_out_of_range) {
// Conversion error

std::stringstream ss;
ss<<a;
ss>>m_ruleId;
if (ss.fail()) {
ss.clear();
m_ruleId = 0;
error->assign("The input \"" + a + "\" does not " \
"seems to be a valid rule id.");
Expand Down