No no, you were right, my patch was 100% broken.
In addition to that I faced some unfortunate mobile specific issue with setSubstitution here:
  https://github.com/mozilla/addon-sdk/pull/811/files#L0R154
I now tested this patch extensively and seems to work fine.