diff --git a/backend.py b/backend.py index 30b7322..d2ee703 100644 --- a/backend.py +++ b/backend.py @@ -6,6 +6,7 @@ from utils.helpers import * import time import json +import html # --- Flask Application Setup --- app = Flask(__name__) @@ -99,6 +100,9 @@ def run_simulation_stream(): if not is_valid: return result + # Escape result to prevent XSS + result = html.escape(result) + # Build command command = build_simulation_command(result) logger.debug(f"Running streaming simulation with command: {' '.join(command)}") diff --git a/src/README.md b/src/README.md index 1d3bf27..6e88fa9 100644 --- a/src/README.md +++ b/src/README.md @@ -1,4 +1,4 @@ -## Modification Notice: simulation.hpp +## Modification Notice: `simulation.hpp` This document describes a modification made to the `simulation.hpp` file, specifically in the `Simulator::printRow` function. The purpose of this change is to enable real-time streaming of simulation output when used with the API, ensuring that data is delivered to the client as soon as it is available. @@ -29,4 +29,4 @@ void Simulator::printRow(double percentage) { ### Future Considerations -If future versions of the library include this feature, this modification may no longer be necessary. Until then, it should be retained to ensure proper streaming behavior. \ No newline at end of file +If future versions of the library include this feature, this modification may no longer be necessary. Until then, it should be retained to ensure proper streaming behavior.