abhinav-upadhyay/apropos_replacement — Issue #62: Quote inline HTML fragments in the snippet in run_query_html(3)
Author: abhinav-upadhyay
Created: 2011-12-02 16:34:36+00:00
State: open

It is possible that the snippet text returned from Sqlite might consist of some inline HTML fragments in which case run_query_html should properly quote special characters like <, >, ", & etc. before calling the callback function supplied by the user.

My strategy is simple:

* Scan the snippet for the number of occurrences of each of the characters in the set {<, >, ", &}
* Allocate a buffer with space large enough to accommodate the snippet with the special characters replaced by their quoted versions ("<"; , ">"; etc.)
* Copy over the snippet to the newly allocated buffer, character by character while checking for special characters and replacing them with their quoted versions.
* Call the user supplied callback function and supply this new buffer as the snippet.
* Free the buffer after the callback returns.