-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Conversation
@taoeffect |
Passing run #2517 ↗︎
Details:
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> { |
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 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?
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.
@taoeffect
I wanted to fix (or avoid) this Flow error.
Which actually doesn't make sense as replaceAll
is a valid method of the string type.
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.
@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.
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.
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
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.
One minor change request relating to Flow parameter typing
closes #2130
[ proof of fix ]
@taoeffect (cc. @corrideat )
That was a bug caused by caveats in how
dompurify
andparseFromString
method of the DOMParser API (reference) interpret<'
,>
and also<
and>
characters. So had to make updates to two places to take them into account.