When using ng-bind-html, the issue arises where it interprets '
' as a closing tag. This results in the text being sanitized and passed through, but when rendered in HTML, it appears as if nothing is displayed beyond the closing tag. For instance, 'I find <code></
is a good thing' only shows 'I find' on the webpage after binding the string.
(additional information)
The root of the problem lies in the conflicting usage of html encoding and url encoding simultaneously. In our current setup, the input from the frontend looks like '</
is good'. This input undergoes encoding via a service, transforming it into '<%2F is good', then ultimately becoming '</ is good' before insertion into the database. Upon retrieval, ng-bind-html interprets this as '</
is good'. The issue is further complicated by an input field with ng-model that receives this data as '$lt/ is good', mirroring the database content. To address this inconsistency, a replace() function is implemented in the controller before editing. While this serves as a temporary fix, uncertainties remain regarding its correctness. Even platforms like StackOverflow face similar challenges, evident in the grey background applied to '</
' due to the rich text editor interpreting it differently. As a workaround, backtick escapes are utilized for this particular string within the text editor display.