-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(VULN-2228): check empty expression.
- Loading branch information
d.zinenko
committed
Nov 29, 2022
1 parent
56465d5
commit 01eb695
Showing
7 changed files
with
66 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# ignore third_party code from clang-format checks | ||
include/uconfig/detail/* | ||
include/uri-template/detail/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <uri-template/uri-template.h> | ||
#include <iostream> | ||
// = "http://example.com/search?q=cat&lang=en"; | ||
// "http://example.com/search{?q,lang}" | ||
|
||
int main() { | ||
try{ | ||
std::string uri; | ||
std::string input_template; | ||
std::cin >> uri; | ||
std::cin >> input_template; | ||
// Parse the template | ||
const URI::Template::Template uri_template = URI::Template::ParseTemplate(input_template); | ||
|
||
// Match it to the URI | ||
// &matched_values can be nullptr if you don't care about values. | ||
std::unordered_map<std::string, URI::Template::VarValue> matched_values; | ||
bool matched = URI::Template::MatchURI(uri_template, uri, &matched_values); | ||
|
||
// Print results | ||
std::cout << std::boolalpha; | ||
std::cout << "Template matched: " << matched << std::endl; | ||
for (const auto& [name, value] : matched_values) { | ||
std::cout << name << "=" << value << std::endl; | ||
} | ||
|
||
// Expand | ||
const std::string expanded_uri = URI::Template::ExpandTemplate(uri_template, matched_values); | ||
std::cout << "Template expanded: " << expanded_uri << std::endl; | ||
} catch (std::exception& exp){ | ||
std::cout << "Error: " << exp.what() << std::endl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters