Repository navigation
Apply percent decoding to resource attributes list #4460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dbarker
merged 9 commits into
open-telemetry:main
from
WyshalZyren:fix-resource-attributes-percent-decode
Aug 23, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f62d624
Apply percent decoding to resource attributes list
WyshalZyren 11ddd9f
Fix Bazel visibility for percent decode utility
WyshalZyren ee16ed2
Fix percent decode test include path
WyshalZyren 078402b
Fix missing newlines in resource files
WyshalZyren a4a45f8
Apply project formatting
WyshalZyren 4b71ae9
Merge branch 'main' into fix-resource-attributes-percent-decode
ThomsonTan abad85d
Address review feedback for percent decoding
WyshalZyren 33e59a2
Fix include-what-you-use diagnostics
WyshalZyren 4b9dd6b
Merge branch 'main' into fix-resource-attributes-percent-decode
dbarker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,58 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #include "percent_decode.h" | ||
|
|
||
| #include <cctype> | ||
| #include <cstddef> | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace resource | ||
| { | ||
| namespace detail | ||
| { | ||
| namespace | ||
| { | ||
|
|
||
| unsigned char HexDigitValue(unsigned char c) noexcept | ||
| { | ||
| return static_cast<unsigned char>(std::isdigit(c) ? c - '0' : std::toupper(c) - 'A' + 10); | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| std::string PercentDecode(const std::string &value) | ||
| { | ||
| std::string decoded; | ||
| decoded.reserve(value.size()); | ||
|
|
||
| for (std::size_t i = 0; i < value.size(); ++i) | ||
| { | ||
| if (value[i] == '%' && i + 2 < value.size()) | ||
| { | ||
| unsigned char high = static_cast<unsigned char>(value[i + 1]); | ||
| unsigned char low = static_cast<unsigned char>(value[i + 2]); | ||
|
|
||
| if (std::isxdigit(high) && std::isxdigit(low)) | ||
| { | ||
| unsigned char unescaped_value = | ||
| static_cast<unsigned char>((HexDigitValue(high) << 4) | HexDigitValue(low)); | ||
|
|
||
| decoded.push_back(static_cast<char>(unescaped_value)); | ||
| i += 2; | ||
| continue; | ||
| } | ||
| } | ||
|
|
||
| decoded.push_back(value[i]); | ||
| } | ||
|
|
||
| return decoded; | ||
| } | ||
|
|
||
| } // namespace detail | ||
| } // namespace resource | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE |
This file contains hidden or 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,25 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "opentelemetry/version.h" | ||
|
|
||
| OPENTELEMETRY_BEGIN_NAMESPACE | ||
| namespace sdk | ||
| { | ||
| namespace resource | ||
| { | ||
| namespace detail | ||
| { | ||
|
|
||
| // Decodes valid percent-encoded sequences in value. | ||
| // Invalid or incomplete percent-encoded sequences are left unchanged. | ||
| std::string PercentDecode(const std::string &value); | ||
|
WyshalZyren marked this conversation as resolved.
Resolved
|
||
|
|
||
| } // namespace detail | ||
| } // namespace resource | ||
| } // namespace sdk | ||
| OPENTELEMETRY_END_NAMESPACE | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.