Skip to content

Commit

Permalink
Fixing algorithm; #529
Browse files Browse the repository at this point in the history
  • Loading branch information
the-moisrex committed Apr 10, 2024
1 parent 91569a6 commit 4ef0c20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions tests/idna_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ TYPED_TEST(IDNATests, LabelSeparators) {
}

TYPED_TEST(IDNATests, MappingFindAlgorithmTest) {
// 'A' should be mapped to 'a'
auto const pos = uri::idna::find_mapping_byte('A');
EXPECT_EQ(*pos, 2'147'483'713ULL)
<< "Position of the iterator: " << stl::distance(uri::idna::details::idna_mapping_table.begin(), pos);
EXPECT_EQ(*stl::next(pos), 'a');
}
5 changes: 2 additions & 3 deletions webpp/uri/idna/idna_mappings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace webpp::uri::idna {
template <typename CharT>
[[nodiscard]] static constexpr details::idna_mapping_table_iterator find_mapping_byte(
CharT const inp_ch) {
using details::disallowed_mask;
using details::idna_mapping_table;
using details::map_table_byte_type;
using details::mapped_mask;
Expand All @@ -66,12 +67,10 @@ namespace webpp::uri::idna {
idna_mapping_table.end(),
byte,
[](map_table_byte_type const lhs, map_table_byte_type const rhs) constexpr noexcept {
return lhs < (rhs | mapped_mask);
return (lhs | disallowed_mask) < (rhs | disallowed_mask);
});

return pos;
// const range_start;
// const range_end;
}

template <istl::String OutStrT, typename Iter>
Expand Down

0 comments on commit 4ef0c20

Please sign in to comment.