Add protection of strings to prevent hijacking of deepl credits. POC! #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
THIS IS A PROOF OF CONCEPT
Todo:
Verify the work ;)
The list provided by the FE (Front-End) with the current code (deepl.ts, other project) must at least be present in the strings generated by this PoC; otherwise, it’s not 100% backward compatible. The idea here is that this should be a drop-in replacement—the FE of, for example, existing implementations should continue to work as before, while this PoC ensures that no abuse can take place. In a new situation, the front-end should no longer need to send strings in the POST (fetch).
Some additional thoughts:
The plugin accepts POST requests with ObjectID = 0 when they are not required in settings. This is to handle cases like Archives. This is not covered by this PoC.
We could implement "if object_id is 0, we take the referrer URL and retrieve the strings from there."
It's safer than the current situation, but the URL must be validated to ensure "it’s really from one of our sites" (which is easy peasy). Caching can then be done based on URL, but that (as said) is not yet implemented.
For the plugin on WordPress.org, it might be useful to include a demo script. Although the plugin does what it is supposed to do, it’s not very useful for someone who finds it without already having something in place for translating the site.