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

Some sort of mapping function #429

Closed
xmo-odoo opened this issue Mar 19, 2024 · 2 comments
Closed

Some sort of mapping function #429

xmo-odoo opened this issue Mar 19, 2024 · 2 comments

Comments

@xmo-odoo
Copy link

One of the biggest issues of markupsafe is that most of the world is not markupsafe-aware, so when performing text transformations through markupsafe-unaware (but safe) APIs. In my experience, regex and markdown are common issues.

They generally require type-checking the input, applying the transformation, then re-wrapping if necessary, commonly transforming a simple expression into several statements (or a more complicated conditional expression).

Would be nice if markupsafe provided a markupsafe.map utility which did that internally, applying a user-supplied transformation function then rewrapping the input to match the output.

@davidism
Copy link
Member

This sounds outside the scope of MarkupSafe. I'm not clear what this would be compared to Markup(markdown.render(value)).

@davidism davidism closed this as not planned Won't fix, can't repro, duplicate, stale Mar 19, 2024
@xmo-odoo
Copy link
Author

xmo-odoo commented Mar 19, 2024

This sounds outside the scope of MarkupSafe. I'm not clear what this would be compared to Markup(markdown.render(value)).

It would check that the original value is a Markup and only re-wrap in that case: if the input of markdown rendering is markup-safe, then the output is generally markup-safe (barring odd extensions).

An unconditional wrapping would launder markup from an unescaped markdown doc into the output. While there are use-cases for that, untrusted input is a pretty big use case for markdown.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants