Test problematic strings when interfacing with libraries

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the encoding category.

Last Updated: 2024-04-25

Quotes

Always check if strings fields can handle single and double quotes if they are being passed to another language (e.g. via JSON) to another system. In Project A, we generated charts of carbon data for various suppliers and only discovered in QA that the graphs all broke when a supplier name had a single quote in it. The fix was a system that properly escaped these entities.

Unicode

In another case, working with the channels library in Django, the presence of a German umlaut or Japanese characters in a username caused the system to break.

Conclusions

In general

test_str = "a'\"hello ü\n"