Skip to content

Commit 74ac61d

Browse files
committed
fix crash on invalid lang str
1 parent 87d0361 commit 74ac61d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/rdf4cpp/Literal.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ Literal Literal::make_typed(std::string_view lexical_form, IRI const &datatype,
198198

199199
if (datatype_identifier == datatypes::rdf::LangString::datatype_id) {
200200
// see: https://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal
201-
throw std::invalid_argument{
202-
"cannot construct rdf:langString without a language tag, please call one of the other factory functions"};
201+
throw InvalidNode{"cannot construct rdf:langString without a language tag, please call one of the other factory functions"};
203202
}
204203

205204
if (datatype_identifier == datatypes::xsd::String::datatype_id) {

tests/parser/tests_IStreamQuadIterator.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,4 +661,14 @@ TEST_SUITE("IStreamQuadIterator") {
661661
run_overread(4096 * 2 + 100);
662662
}
663663
}
664-
}
664+
665+
TEST_CASE("lang tagged literal in datatype style") {
666+
std::istringstream iss{R"(<http://a.com#s> <http://a.com#p> "AA"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#langString> .)"};
667+
IStreamQuadIterator qit{iss};
668+
669+
for (; qit != std::default_sentinel; ++qit) {
670+
REQUIRE(!qit->has_value());
671+
CHECK_EQ(qit->error().error_type, ParsingError::Type::BadLiteral);
672+
}
673+
}
674+
}

0 commit comments

Comments
 (0)