Fix escape char#957
Open
Shriyans406 wants to merge 3 commits intorust-embedded:masterfrom
Open
Conversation
burrbull
reviewed
Apr 25, 2026
| escaped = escaped.replace('&', "&"); | ||
| } | ||
| if escaped.contains('<') { | ||
| escaped = escaped.replace('<', "<"); |
Member
There was a problem hiding this comment.
svd string can contain valid html tags. How do you propose to process such cases?
Author
|
Thank you for the feedback! Escaping of < and > would break HTML formatting
in the SVD.
I've updated the implementation to be more selective, it now uses a regex
to identify and preserve HTML tags (like <b>) and entities (like &),
while still escaping characters (like & and < that aren't part of a tag) to
prevent them from being misinterpreted.
I've also added unit tests covering these cases.
Is it fine?
…On Sat, Apr 25, 2026 at 5:42 PM Zgarbul Andrey ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/util.rs
<#957 (comment)>
:
> @@ -179,11 +179,24 @@ pub fn escape_brackets(s: &str) -> String {
/// Escape basic html tags and brackets
pub fn escape_special_chars(s: &str) -> Cow<'_, str> {
- if s.contains('[') {
- escape_brackets(s).into()
- } else {
- s.into()
+ if !s.contains('[') && !s.contains('&') && !s.contains('<') && !s.contains('>'){
+ return s.into();
+ }
+ let mut escaped = s.to_string();
+ if escaped.contains('&') {
+ escaped = escaped.replace('&', "&");
+ }
+ if escaped.contains('<') {
+ escaped = escaped.replace('<', "<");
svd string can contain valid html tags. How do you propose to process such
cases?
—
Reply to this email directly, view it on GitHub
<#957 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BMTFX7WEFIQ7BN3DJBSO7F34XSTRJAVCNFSM6AAAAACYBIWM5GVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHM2DCNZVGUYTMNJWGM>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/BMTFX7RMY2FRGAQQ24KR5TT4XSTRJA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTIMJXGU2TCNRVGYZ2M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KUZTPN52GK4S7NFXXG>
and Android
<https://github.com/notifications/mobile/android/BMTFX7V5WUSVYUXUD5WCTMT4XSTRJA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTIMJXGU2TCNRVGYZ2M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2K4ZTPN52GK4S7MFXGI4TPNFSA>.
Download it today!
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Member
|
I don't see any changes in this PR. |
Author
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR ensures that characters like &, <, and > are escaped or avoided in SVD descriptions so that they don't break generated Rust docs