An app generates a PDF based on user entered data in text fields. Copying and pasting users can inadvertently end up pasting "tags" in the field. Eg -


The PDF generator plugin does not like this and crashes throwing an exception. The App vendor says this "escaping needs to be done on the plugin side" as all their tools/plugins are similar - escaping for sql injection, cross site etc. The plugin vendor says the App vendor needs to escape the tags.

My initial thoughts are that this is not enough for a catastrophic error that the plugin throws. I would have liked a PDF to still be generated but with a message "Something went wrong, problem with..." or just ignore the unknown tag and show it as is in the PDF (I've seen this before in a business app). But I'm not sure which side this nice error handling falls on.

In terms of software design, app vs plugin, which side is responsible objectively in this case?

App takes data from the database (originally user entered) and prepares a basic HTML string for conversion, eg in a the App's controller action:

$html = "<html>...<p>$userNotes</p>...</html>";
return Response($this->plugin->htmlToPDF($html));
  • What parts of this description are the app, what are the plugin? You aren't describing the App <--> Plugin data flows – Caleth Oct 26 '18 at 13:36
  • 5
    I didn't downvote, but I can make an educated guess. Your question doesn't really have much to do with software engineering. We don't settle contractual disputes here. – Robert Harvey Oct 26 '18 at 15:10
  • are you sure, in terms of plugin architecture vs main app architecture? – user95437 Nov 19 '18 at 10:56

In the end this is a contractual or interpersonal matter, not technical.

However, there might be some technical considerations. The app usually presents a particular plugin interface. Plugin vendors will have to comply with this interface. If the documented interface deals with unescaped data, the plugin vendor will have to perform the necessary escaping.

In fact, it might be impossible to properly sanitize or escape the data prior to handing it off to a plugin. Different formats have different escaping rules. There is no one format that will be acceptable to all plugins. If the plugins were handed escaped data, most plugins would have to un-escape it first.

As an example of this difficulty, consider user input that contains a " double quote character. How would this have to be escaped for different formats?

  • JSON, SQL1: backslash-escapes: \"
  • XML, HTML: character reference &34; or &quot;, sometimes no escape needed
  • some CSV dialects: repetition: ""
  • POSIX shell: backslash-escape\" or single-quotes: '"'
  • CMD shell: caret ^", sometimes no escape needed

1 Manual escaping for SQL is usually inappropriate, as prepared statements should be preferred.

Similar considerations not only apply for “special characters”, but also for character encodings like UTF-8: the same encoding will not be accepted by all consumers, so the encoding needs to be documented and converted explicitly.

  • Thanks for the constructive answer. I guess I should have reworded my question to make it more a techincal questions, how to design a good plugin etc. – user95437 Nov 19 '18 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.