-
Notifications
You must be signed in to change notification settings - Fork 540
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
[Shared] Fix Markdown parse issue #4481
Conversation
@@ -263,7 +263,7 @@ bool EmphasisParser::IsLeftEmphasisDelimiter(const char ch) const | |||
|
|||
bool EmphasisParser::IsRightEmphasisDelimiter(const char ch) const | |||
{ | |||
if ((ch == EOF || MarkDownBlockParser::IsSpace(ch)) && (m_lookBehind != DelimiterType::WhiteSpace) && | |||
if ((ch == EOF || ch == '\xff' || MarkDownBlockParser::IsSpace(ch)) && (m_lookBehind != DelimiterType::WhiteSpace) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this needed for Android? and why is it needed now?
This looks to be a gap in our testing; Can we add a test card for this at the very least with this change? Is it possible to cover this with existing sharedmodel unit tests? @RebeccaAnne |
@@ -263,7 +263,7 @@ bool EmphasisParser::IsLeftEmphasisDelimiter(const char ch) const | |||
|
|||
bool EmphasisParser::IsRightEmphasisDelimiter(const char ch) const | |||
{ | |||
if ((ch == EOF || MarkDownBlockParser::IsSpace(ch)) && (m_lookBehind != DelimiterType::WhiteSpace) && | |||
if ((ch == EOF || ch == '\xff' || MarkDownBlockParser::IsSpace(ch)) && (m_lookBehind != DelimiterType::WhiteSpace) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is now a complicated enough condition to warrant a quick explanatory code comment pls!
The Markdown parser looks like it should have unit tests for this? @RebeccaAnne, does it? Refers to: source/shared/cpp/ObjectModel/MarkDownBlockParser.cpp:10 in f6f5cac. [](commit_id = f6f5cac, deletion_comment = False) |
This is not a gap in testing, this is an issue about the device it's been deployed, in emulators everything works as expected while in devices it doesn't. As of this moment there are tests in the c++ side that verify that everything works as expected, we could add tests on Android but the tests would still yield "false positives" on emulators |
Yeah, the unit tests didn't catch it because it is non-deterministic (it happens on some devices, based on the c++ implementation). @jwoo-msft The bug isn't actually new, it seems to have been introduced as part of #3342 last year. But we recently brought that change from main to release with #4309. Hence, Teams is now seeing it. As for why it works on some platforms: C++ standard doesn't define whether 'char' is signed or unsigned. It's up to the compiler. The compiler usually makes this decision based on what the target device architecture prefers. We can verify this by looking at CHAR_MIN (which is 0 if char is unsigned char, and -128 if its signed). This is what I see if I debug in the emulator: The issue occurs if the compiler decided 'char' is an unsigned char. So EOF (which is This was just a draft PR, but I think the proper solution is to revert ch to int (unless there was a specific reason for that change?), or perhaps switching char to explicit signed char would work (but I think we would lose access to special characters if we do that? I'm not sure..). Thoughts? @paulcam206 |
I see. Yes, #3342 added support for non-Latin language support, and as I added new markdown list marker support '+', and '*', I noticed that #3342 was not picked up, and it's an important fix, so I added it. |
Hi @golddove. This non-spec pull request has had no recent activity for the past 5 days . Please take the necessary actions (review, address feedback or commit if reviewed already) to move this along. |
I think switching to |
Hi @paulcam206; Thanks for commenting on this previously stale pull request. Resetting staleness. @golddove FYI. |
fixed compiler warnings and updated IsAlphaNum function to be able to use with int; |
Great find guys! |
@golddove /@paulcam206, this looks like it would need to be ported back to 1.2? |
@@ -739,19 +739,19 @@ namespace AdaptiveCardsSharedModelUnitTest | |||
MarkDownParser parser(""); | |||
Assert::AreEqual<bool>(false, parser.IsEscaped()); | |||
|
|||
parser.TransformToHtml(); | |||
(void) parser.TransformToHtml(); | |||
Assert::AreEqual<bool>(false, parser.IsEscaped()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool these are the tests I was looking for then! Tx
* Fix Markdown parse issue * Revert char casts * Fixed compilation errors & updated IsAlphaNumeric function & fixed existing compilation warnings * added EOF check in IsAlphaNum() * removed casting Co-authored-by: nesalang <nesalang@gmail.com>
* Cherry-pick of #4481 Co-authored-by: nesalang <nesalang@gmail.com>
* Fix Markdown parse issue * Revert char casts * Fixed compilation errors & updated IsAlphaNumeric function & fixed existing compilation warnings * added EOF check in IsAlphaNum() * removed casting Co-authored-by: nesalang <nesalang@gmail.com>
Related Issue
Fixes #4463
Description
Markdown emphasis parsing for was broken on Android devices.
How Verified
Manual testing
Microsoft Reviewers: Open in CodeFlow