Skip to content
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

#2130 - Chat rendering issue re handling '<' and '>' character #2139

Merged
merged 6 commits into from
Jul 1, 2024

Conversation

SebinSong
Copy link
Collaborator

@SebinSong SebinSong commented Jun 29, 2024

closes #2130

[ proof of fix ]

@taoeffect (cc. @corrideat )
That was a bug caused by caveats in how dompurify and parseFromString method of the DOMParser API (reference) interpret <',> and also &lt; and &gt; characters. So had to make updates to two places to take them into account.

@SebinSong SebinSong self-assigned this Jun 29, 2024
@SebinSong
Copy link
Collaborator Author

@taoeffect
Another verification in more complex context:

Copy link

cypress bot commented Jun 30, 2024

Passing run #2517 ↗︎

0 114 8 0 Flakiness 0

Details:

Merge c2d42c7 into 8eaac96...
Project: group-income Commit: 5aedad6bef ℹ️
Status: Passed Duration: 10:33 💡
Started: Jul 1, 2024 11:03 PM Ended: Jul 1, 2024 11:14 PM

Review all test suite changes for PR #2139 ↗︎

@@ -5,12 +5,19 @@ export type DomObject = {
children?: Array<DomObject>
}

export function htmlStringToDomObjectTree (htmlString: string): Array<DomObject> {
export function htmlStringToDomObjectTree (htmlString: any): Array<DomObject> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this updated to any? What besides string can it be? If it can be one of two types, then maybe it should be changed to a union of two types?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taoeffect
I wanted to fix (or avoid) this Flow error.

image

Which actually doesn't make sense as replaceAll is a valid method of the string type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SebinSong if flow is being dumb then you can add a comment above the broken line like this:

// $FlowFixMe[prop-missing]

It's better to get the type information in the parameters right and add a comment like this than use the wrong type information because it could mislead other developers looking at this code into thinking they can pass anything to the function.

Copy link
Collaborator

@snowteamer snowteamer Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SebinSong

Which actually doesn't make sense as replaceAll is a valid method of the string type.

This is true but wasn't the case when this older Flow version (0.154.0) was released

Copy link
Member

@taoeffect taoeffect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor change request relating to Flow parameter typing

@taoeffect taoeffect merged commit cee60cf into master Jul 1, 2024
4 checks passed
@taoeffect taoeffect deleted the sebin/task/#2130-chat-rendering-issue branch July 1, 2024 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Chat rendering issues
3 participants