Skip to content

Conversation

@nattsw
Copy link
Contributor

@nattsw nattsw commented Feb 19, 2025

As much as we would like to trust AI / translation API outputs, we're adding a bit of sanitisation here for simple things like script tags in case.

@nattsw nattsw marked this pull request as draft February 19, 2025 09:34
@nattsw
Copy link
Contributor Author

nattsw commented Feb 19, 2025

⚠️ This PR will need a compat version update.

module DiscourseTranslator
class TranslatedContentSanitizer
def self.sanitize(content)
PrettyText.cleanup(content, {})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The sanitizer only calls prettytext for now.

In general I would be moving towards creating specific classes as we may see this function expand.

@@ -1,3 +1,4 @@
< 3.5.0.beta2-dev: 5f24835801fdc7cb98e1bcf42d2ab2e49e609921
Copy link
Contributor Author

@nattsw nattsw Feb 25, 2025

Choose a reason for hiding this comment

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

Made a mistake in my previous compat file update...

We are on 3.5.0.beta2-dev now, and the commit before this one is 5f24835801fdc7cb98e1bcf42d2ab2e49e609921.

This PR uses PrettyText.cleanup(content, {}) which is new in core.

@nattsw nattsw marked this pull request as ready for review February 25, 2025 03:37
@nattsw nattsw merged commit fa66f1a into main Feb 26, 2025
5 checks passed
@nattsw nattsw deleted the sanitise-ai-output branch February 26, 2025 06:09
@nattsw
Copy link
Contributor Author

nattsw commented Feb 26, 2025

ty @tyb-talks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants