Add JSON escaping for multi-line content strings

This commit is contained in:
Z. Cliffe Schreuders
2026-01-14 09:46:32 +00:00
parent 30395481cd
commit d99a6370a0

View File

@@ -1,6 +1,7 @@
<%
# ERB Helper Methods for Mission 3: Ghost in the Machine
require 'base64'
require 'json'
# Encoding helper functions
def rot13(text)
@@ -15,6 +16,10 @@ def hex_encode(text)
text.unpack('H*').first
end
def json_escape(text)
text.to_json[1..-2] # Remove surrounding quotes from .to_json output
end
# Narrative content variables
whiteboard_message_encoded = rot13("MEET WITH THE ARCHITECT - PRIORITIZE INFRASTRUCTURE EXPLOITS")
@@ -410,7 +415,7 @@ operational_log_content = "TRANSACTION LOG - Q3 2024\n\n[2024-09-15 14:32:11] Pr
"id": "lore_fragment_2_doc",
"name": "Q3 2024 Exploit Catalog",
"type": "lore_document",
"content": "<%= lore_fragment_2 %>",
"content": "<%= json_escape(lore_fragment_2) %>",
"completes_task": "lore_fragment_2"
}
]
@@ -488,7 +493,7 @@ operational_log_content = "TRANSACTION LOG - Q3 2024\n\n[2024-09-15 14:32:11] Pr
"name": "Operational Logs",
"type": "document",
"position": {"x": 4, "y": 4},
"content": "<%= operational_log_content %>",
"content": "<%= json_escape(operational_log_content) %>",
"completes_task": "find_operational_logs"
}
},
@@ -549,7 +554,7 @@ operational_log_content = "TRANSACTION LOG - Q3 2024\n\n[2024-09-15 14:32:11] Pr
"id": "lore_fragment_1_doc",
"name": "Zero Day: A Brief History",
"type": "lore_document",
"content": "<%= lore_fragment_1 %>",
"content": "<%= json_escape(lore_fragment_1) %>",
"completes_task": "lore_fragment_1"
}
]