hainenber commented on PR #32294:
URL: https://github.com/apache/superset/pull/32294#issuecomment-2670446919

   > Does that library properly escape the single quote and solve the problem 
without changing the text?
   
   The library fixes the input string in best effort approach and at least 
returns JSON-compliant object.
   
   <img width="1212" alt="image" 
src="https://github.com/user-attachments/assets/077a3aa6-bd6a-4b54-a13c-7dd4b5a28d64";
 />
   
   > I'm worried there may be any number of strings throughout the codebase 
with apostrophes, and hope we can handle them properly rather than work around 
them.
   
   This is going to be tedious so that's why I added a failsafe with 
`jsonrepair`. What do you think of initially parse input data with native 
`JSON.parse` and if failed, fixes the input string and reparse again?
   
   ```
   export default function getBootstrapData(): BootstrapData {
     const appContainer = document.getElementById('app');
     const dataBootstrapString = appContainer?.getAttribute('data-bootstrap');
     if (!dataBootstrapString) {
       return DEFAULT_BOOTSTRAP_DATA
     }
   
     try {
       return JSON.parse(dataBootstrapString) 
     } catch (error) {
       return JSON.parse(jsonrepair(dataBootstrapString))
     }
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to