Check for illegal characters while parsing input.

This commit is contained in:
Alek Mosingiewicz 2018-05-15 19:25:28 +02:00
parent c09af92963
commit 322568ba39

View File

@ -530,6 +530,9 @@ namespace chaiscript
bool retval = false; bool retval = false;
while (m_position.has_more()) { while (m_position.has_more()) {
if(static_cast<size_t>(*m_position) > 0x7e) {
throw exception::eval_error("Illegal character", File_Position(m_position.line, m_position.col), *m_filename);
}
auto end_line = (*m_position != 0) && ((*m_position == '\n') || (*m_position == '\r' && *(m_position+1) == '\n')); auto end_line = (*m_position != 0) && ((*m_position == '\n') || (*m_position == '\r' && *(m_position+1) == '\n'));
if ( char_in_alphabet(*m_position,detail::white_alphabet) || (skip_cr && end_line)) { if ( char_in_alphabet(*m_position,detail::white_alphabet) || (skip_cr && end_line)) {
@ -2569,9 +2572,9 @@ namespace chaiscript
m_position = Position(t_input.begin(), t_input.end()); m_position = Position(t_input.begin(), t_input.end());
m_filename = std::make_shared<std::string>(std::move(t_fname)); m_filename = std::make_shared<std::string>(std::move(t_fname));
if (detail::Char_Parser_Helper<std::string>::has_utf8_bom(t_input)) { //if (detail::Char_Parser_Helper<std::string>::has_utf8_bom(t_input)) {
throw exception::eval_error("UTF-8 in user provided input!"); // throw exception::eval_error("UTF-8 in user provided input!");
} //}
if ((t_input.size() > 1) && (t_input[0] == '#') && (t_input[1] == '!')) { if ((t_input.size() > 1) && (t_input[0] == '#') && (t_input[1] == '!')) {
while (m_position.has_more() && (!Eol())) { while (m_position.has_more() && (!Eol())) {