RIFT-15068: Encoded strings in VNFR/NSR output cause record details view to fail... 51/651/1
authorKIRAN KASHALKAR <kiran.kashalkar@riftio.com>
Wed, 9 Nov 2016 22:13:10 +0000 (17:13 -0500)
committerKIRAN KASHALKAR <kiran.kashalkar@riftio.com>
Wed, 9 Nov 2016 22:14:06 +0000 (17:14 -0500)
Signed-off-by: KIRAN KASHALKAR <kiran.kashalkar@riftio.com>
skyquake/plugins/launchpad/src/recordViewer/recordDetails.jsx

index 0a3e35e..9b35d1b 100644 (file)
@@ -27,7 +27,17 @@ export default class RecordDetails extends React.Component{
   }
   render(){
     let html;
-    let text = JSON.stringify(this.props.data, undefined, 2);
+    // Prism can't handle escaped \n and other characters
+    let text = JSON.stringify(this.props.data, undefined, 2)
+                .replace(/\r\n/g, '\n')
+                .replace(/\\\\n/g, "\n")
+                .replace(/\\\\'/g, "\'")
+                .replace(/\\\\"/g, '\"')
+                .replace(/\\\\&/g, "\&")
+                .replace(/\\\\r/g, "\r")
+                .replace(/\\\\t/g, "\t")
+                .replace(/\\\\b/g, "\b")
+                .replace(/\\\\f/g, "\f");
     // html = this.props.isLoading ? <LoadingIndicator size={10} show={true} /> : <pre className="json">{JSON.stringify(this.props.data, undefined, 2)}</pre>;
     html = this.props.isLoading ? <LoadingIndicator size={10} show={true} /> : Prism.highlight(text, Prism.languages.javascript, 'javascript');
     return (