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

tag-like (but not valid HTML tag) text should be escaped #596

Open
isoos opened this issue Mar 15, 2024 · 12 comments
Open

tag-like (but not valid HTML tag) text should be escaped #596

isoos opened this issue Mar 15, 2024 · 12 comments

Comments

@isoos
Copy link

isoos commented Mar 15, 2024

Markdown version: 7.2.2 using GitHubWeb extension set.
Originally reported: dart-lang/pub-dev#7559

Input:

Future<List<EntityAnnotation>> **labelDetection**

<EntityAnnotation>

Output:

<p>Future&lt;List<EntityAnnotation>&gt; <strong>labelDetection</strong></p>
<EntityAnnotation>

Expected: <EntityAnnotation> is also escaped to &lt;EntityAnnotation&gt;.

@isoos
Copy link
Author

isoos commented Mar 15, 2024

/cc @chenzhiguang @devoncarew

@srawlins
Copy link
Member

I don't think this is a bug. I think this is working as expected. Most CommonMark-compliant Markdown implementations do not escape <EntityAnnotation>.

https://babelmark.github.io/?text=Future%3CList%3CEntityAnnotation%3E%3E+**labelDetection**%0A%0A%3CEntityAnnotation%3E

@isoos
Copy link
Author

isoos commented Mar 15, 2024

/cc @jonasfj

I'm not sure what's the best strategy would be here, but maybe we could apply an escaping before running it through HTML sanitization?

@srawlins
Copy link
Member

cc @kallentu I think we should just be linting text like this, that is reported by the analyzer. This text should just be in backticks.

@jonasfj
Copy link
Member

jonasfj commented Mar 15, 2024

In backticks or brackets if you want to link to the types, right/maybe?

@srawlins
Copy link
Member

Ehhhh. 😁 The formats that the analyzer accepts in square brackets is a short list 😦 . Basically [Foo], [Foo.foo], and [foo.Foo.foo]. So [List<int>] doesn't work, but I would love for it to work some day.

But yes, "in backticks or brackets."

@jonasfj
Copy link
Member

jonasfj commented Mar 15, 2024

Uh, I guess that makes sense.

@faithoflifedev
Copy link

As an FYI, it appears that using:

Future<List\<EntityAnnotation>> **labelDetection**

Notice the \<

Will trick the system into creating html that displays correctly on Github and pub.dev

@isoos
Copy link
Author

isoos commented Mar 17, 2024

Will trick the system into creating html that displays correctly on Github and pub.dev

@faithoflifedev: I think it may produce an <EntityAnnotation> String text in the markdown output, but pub.dev should filter it out with HTML sanitization. Do you have any example page where we are not filtering it?

@faithoflifedev
Copy link

Do you have any example page where we are not filtering it?

Hi @isoos, I originally opened the Issue #7557 that led to this discussion. If I understand your question correctly then you should see an example here - https://pub.dev/packages/google_vision/versions/1.2.0+6#new-helper-methods - you can campare this with - https://pub.dev/packages/google_vision/versions/1.2.0+5#new-helper-methods - where in the first link the HTML is rendered as would be expected by the user (i.e. <EntityAnnotation> is displayed), while on the second link <EntityAnnotation> is missing on the 4th row since the \< workaround was not used.

@isoos
Copy link
Author

isoos commented Mar 17, 2024

@faithoflifedev: to be clear, the linked page source has &lt;EntityAnnotation&gt; content, and not <EntityAnnotation> in the sources (in other words: the HTML sanitization is working as expected, the "trick" is for the markdown rendering).

@faithoflifedev
Copy link

@isoos, understood - my initial problem was the HTML render difference between pub.dev and github.com, which can be resolved with the workaround. From my perspective there's no need for me to pursue this.

From an overall end-user perspective there may be a perception that a README on github.com will render the same on pub.dev, I'll leave that up to the "collective" you to resolve as you see fit 😄

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

No branches or pull requests

4 participants