diff --git a/labs/lab-04/menu.js b/labs/lab-04/menu.js
index 3ac117c..2266346 100644
--- a/labs/lab-04/menu.js
+++ b/labs/lab-04/menu.js
@@ -1,3 +1,13 @@
+// Экранирование данных перед вставкой в HTML (данные приходят из общего учебного API)
+function esc(value) {
+ return String(value ?? '')
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+}
+
const selectedDishes = {
soup: null,
'main-course': null,
@@ -36,11 +46,11 @@ function displayDishes() {
function createDishCard(dish) {
return `
-
-
-
${dish.price} руб.
-
${dish.name}
-
${dish.count}
+
+
+
${esc(dish.price)} руб.
+
${esc(dish.name)}
+
${esc(dish.count)}
`;
@@ -87,8 +97,8 @@ function updateOrderSummary() {
Суп
- ${selectedDishes.soup.name}
- ${selectedDishes.soup.price} руб.
+ ${esc(selectedDishes.soup.name)}
+ ${esc(selectedDishes.soup.price)} руб.
`;
@@ -107,8 +117,8 @@ function updateOrderSummary() {
Главное блюдо
- ${selectedDishes['main-course'].name}
- ${selectedDishes['main-course'].price} руб.
+ ${esc(selectedDishes['main-course'].name)}
+ ${esc(selectedDishes['main-course'].price)} руб.
`;
@@ -127,8 +137,8 @@ function updateOrderSummary() {
Напиток
- ${selectedDishes.drink.name}
- ${selectedDishes.drink.price} руб.
+ ${esc(selectedDishes.drink.name)}
+ ${esc(selectedDishes.drink.price)} руб.
`;
diff --git a/labs/lab-05/menu.js b/labs/lab-05/menu.js
index 9f377ff..3a62415 100644
--- a/labs/lab-05/menu.js
+++ b/labs/lab-05/menu.js
@@ -1,3 +1,13 @@
+// Экранирование данных перед вставкой в HTML (данные приходят из общего учебного API)
+function esc(value) {
+ return String(value ?? '')
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+}
+
const selectedDishes = {
soup: null,
'main-course': null,
@@ -66,11 +76,11 @@ function displayDishes() {
function createDishCard(dish) {
return `
-
-
-
${dish.price} руб.
-
${dish.name}
-
${dish.count}
+
+
+
${esc(dish.price)} руб.
+
${esc(dish.name)}
+
${esc(dish.count)}
`;
@@ -119,8 +129,8 @@ function updateOrderSummary() {
Суп
- ${selectedDishes.soup.name}
- ${selectedDishes.soup.price} руб.
+ ${esc(selectedDishes.soup.name)}
+ ${esc(selectedDishes.soup.price)} руб.
`;
@@ -139,8 +149,8 @@ function updateOrderSummary() {
Главное блюдо
- ${selectedDishes['main-course'].name}
- ${selectedDishes['main-course'].price} руб.
+ ${esc(selectedDishes['main-course'].name)}
+ ${esc(selectedDishes['main-course'].price)} руб.
`;
@@ -159,8 +169,8 @@ function updateOrderSummary() {
Салат
- ${selectedDishes.salad.name}
- ${selectedDishes.salad.price} руб.
+ ${esc(selectedDishes.salad.name)}
+ ${esc(selectedDishes.salad.price)} руб.
`;
@@ -179,8 +189,8 @@ function updateOrderSummary() {
Напиток
- ${selectedDishes.drink.name}
- ${selectedDishes.drink.price} руб.
+ ${esc(selectedDishes.drink.name)}
+ ${esc(selectedDishes.drink.price)} руб.
`;
@@ -199,8 +209,8 @@ function updateOrderSummary() {
Десерт
- ${selectedDishes.dessert.name}
- ${selectedDishes.dessert.price} руб.
+ ${esc(selectedDishes.dessert.name)}
+ ${esc(selectedDishes.dessert.price)} руб.
`;
diff --git a/labs/lab-06/menu.js b/labs/lab-06/menu.js
index 8b4d424..f30bde4 100644
--- a/labs/lab-06/menu.js
+++ b/labs/lab-06/menu.js
@@ -1,3 +1,13 @@
+// Экранирование данных перед вставкой в HTML (данные приходят из общего учебного API)
+function esc(value) {
+ return String(value ?? '')
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+}
+
const selectedDishes = {
soup: null,
'main-course': null,
@@ -67,11 +77,11 @@ function displayDishes() {
function createDishCard(dish) {
return `
-
-
-
${dish.price} руб.
-
${dish.name}
-
${dish.count}
+
+
+
${esc(dish.price)} руб.
+
${esc(dish.name)}
+
${esc(dish.count)}
`;
@@ -99,7 +109,7 @@ function selectDish(dish) {
if (previousDish) {
const previousCard = document.querySelector(
- `.dish-card[data-dish="${previousDish.keyword}"]`
+ `.dish-card[data-dish="${esc(previousDish.keyword)}"]`
);
if (previousCard) {
previousCard.classList.remove('selected');
@@ -109,7 +119,7 @@ function selectDish(dish) {
selectedDishes[dish.category] = dish;
const currentCard = document.querySelector(
- `.dish-card[data-dish="${dish.keyword}"]`
+ `.dish-card[data-dish="${esc(dish.keyword)}"]`
);
if (currentCard) {
currentCard.classList.add('selected');
@@ -139,8 +149,8 @@ function updateOrderSummary() {
Суп
- ${selectedDishes.soup.name}
- ${selectedDishes.soup.price} руб.
+ ${esc(selectedDishes.soup.name)}
+ ${esc(selectedDishes.soup.price)} руб.
`;
@@ -159,8 +169,8 @@ function updateOrderSummary() {
Главное блюдо
- ${selectedDishes['main-course'].name}
- ${selectedDishes['main-course'].price} руб.
+ ${esc(selectedDishes['main-course'].name)}
+ ${esc(selectedDishes['main-course'].price)} руб.
`;
@@ -179,8 +189,8 @@ function updateOrderSummary() {
Салат
- ${selectedDishes.salad.name}
- ${selectedDishes.salad.price} руб.
+ ${esc(selectedDishes.salad.name)}
+ ${esc(selectedDishes.salad.price)} руб.
`;
@@ -199,8 +209,8 @@ function updateOrderSummary() {
Напиток
- ${selectedDishes.drink.name}
- ${selectedDishes.drink.price} руб.
+ ${esc(selectedDishes.drink.name)}
+ ${esc(selectedDishes.drink.price)} руб.
`;
@@ -219,8 +229,8 @@ function updateOrderSummary() {
Десерт
- ${selectedDishes.dessert.name}
- ${selectedDishes.dessert.price} руб.
+ ${esc(selectedDishes.dessert.name)}
+ ${esc(selectedDishes.dessert.price)} руб.
`;
@@ -367,7 +377,7 @@ function restoreSelection() {
const dish = selectedDishes[category];
if (dish) {
const card = document.querySelector(
- `.dish-card[data-dish="${dish.keyword}"]`
+ `.dish-card[data-dish="${esc(dish.keyword)}"]`
);
if (card) {
card.classList.add('selected');
@@ -380,7 +390,7 @@ function resetSelection() {
Object.keys(selectedDishes).forEach(function(category) {
if (selectedDishes[category]) {
const card = document.querySelector(
- `.dish-card[data-dish="${selectedDishes[category].keyword}"]`
+ `.dish-card[data-dish="${esc(selectedDishes[category].keyword)}"]`
);
if (card) {
card.classList.remove('selected');
diff --git a/labs/lab-07/menu.js b/labs/lab-07/menu.js
index abaa782..6771e89 100644
--- a/labs/lab-07/menu.js
+++ b/labs/lab-07/menu.js
@@ -1,3 +1,13 @@
+// Экранирование данных перед вставкой в HTML (данные приходят из общего учебного API)
+function esc(value) {
+ return String(value ?? '')
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+}
+
let dishes = [];
const selectedDishes = {
@@ -90,11 +100,11 @@ function displayDishes() {
function createDishCard(dish) {
return `
-
-
-
${dish.price} руб.
-
${dish.name}
-
${dish.count}
+
+
+
${esc(dish.price)} руб.
+
${esc(dish.name)}
+
${esc(dish.count)}
`;
@@ -122,7 +132,7 @@ function selectDish(dish) {
if (previousDish) {
const previousCard = document.querySelector(
- `.dish-card[data-dish="${previousDish.keyword}"]`
+ `.dish-card[data-dish="${esc(previousDish.keyword)}"]`
);
if (previousCard) {
previousCard.classList.remove('selected');
@@ -132,7 +142,7 @@ function selectDish(dish) {
selectedDishes[dish.category] = dish;
const currentCard = document.querySelector(
- `.dish-card[data-dish="${dish.keyword}"]`
+ `.dish-card[data-dish="${esc(dish.keyword)}"]`
);
if (currentCard) {
currentCard.classList.add('selected');
@@ -163,8 +173,8 @@ function updateOrderSummary() {
Суп
- ${selectedDishes.soup.name}
- ${selectedDishes.soup.price} руб.
+ ${esc(selectedDishes.soup.name)}
+ ${esc(selectedDishes.soup.price)} руб.
`;
@@ -183,8 +193,8 @@ function updateOrderSummary() {
Главное блюдо
- ${selectedDishes['main-course'].name}
- ${selectedDishes['main-course'].price} руб.
+ ${esc(selectedDishes['main-course'].name)}
+ ${esc(selectedDishes['main-course'].price)} руб.
`;
@@ -203,8 +213,8 @@ function updateOrderSummary() {
Салат
- ${selectedDishes.salad.name}
- ${selectedDishes.salad.price} руб.
+ ${esc(selectedDishes.salad.name)}
+ ${esc(selectedDishes.salad.price)} руб.
`;
@@ -223,8 +233,8 @@ function updateOrderSummary() {
Напиток
- ${selectedDishes.drink.name}
- ${selectedDishes.drink.price} руб.
+ ${esc(selectedDishes.drink.name)}
+ ${esc(selectedDishes.drink.price)} руб.
`;
@@ -243,8 +253,8 @@ function updateOrderSummary() {
Десерт
- ${selectedDishes.dessert.name}
- ${selectedDishes.dessert.price} руб.
+ ${esc(selectedDishes.dessert.name)}
+ ${esc(selectedDishes.dessert.price)} руб.
`;
@@ -391,7 +401,7 @@ function restoreSelection() {
const dish = selectedDishes[category];
if (dish) {
const card = document.querySelector(
- `.dish-card[data-dish="${dish.keyword}"]`
+ `.dish-card[data-dish="${esc(dish.keyword)}"]`
);
if (card) {
card.classList.add('selected');
@@ -404,7 +414,7 @@ function resetSelection() {
Object.keys(selectedDishes).forEach(function(category) {
if (selectedDishes[category]) {
const card = document.querySelector(
- `.dish-card[data-dish="${selectedDishes[category].keyword}"]`
+ `.dish-card[data-dish="${esc(selectedDishes[category].keyword)}"]`
);
if (card) {
card.classList.remove('selected');
diff --git a/labs/lab-08/js/menu.js b/labs/lab-08/js/menu.js
index 0e74905..de45037 100644
--- a/labs/lab-08/js/menu.js
+++ b/labs/lab-08/js/menu.js
@@ -1,3 +1,13 @@
+// Экранирование данных перед вставкой в HTML (данные приходят из общего учебного API)
+function esc(value) {
+ return String(value ?? '')
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+}
+
let dishes = [];
const selectedDishes = {
@@ -104,11 +114,11 @@ function displayDishes() {
function createDishCard(dish) {
return `
-
-
-
${dish.price} руб.
-
${dish.name}
-
${dish.count}
+
+
+
${esc(dish.price)} руб.
+
${esc(dish.name)}
+
${esc(dish.count)}
`;
@@ -136,7 +146,7 @@ function selectDish(dish) {
if (previousDish) {
const previousCard = document.querySelector(
- `.dish-card[data-dish="${previousDish.keyword}"]`
+ `.dish-card[data-dish="${esc(previousDish.keyword)}"]`
);
if (previousCard) {
previousCard.classList.remove('selected');
@@ -146,7 +156,7 @@ function selectDish(dish) {
selectedDishes[dish.category] = dish;
const currentCard = document.querySelector(
- `.dish-card[data-dish="${dish.keyword}"]`
+ `.dish-card[data-dish="${esc(dish.keyword)}"]`
);
if (currentCard) {
currentCard.classList.add('selected');
@@ -298,7 +308,7 @@ function restoreSelection() {
const dish = selectedDishes[category];
if (dish) {
const card = document.querySelector(
- `.dish-card[data-dish="${dish.keyword}"]`
+ `.dish-card[data-dish="${esc(dish.keyword)}"]`
);
if (card) {
card.classList.add('selected');
diff --git a/labs/lab-08/js/order.js b/labs/lab-08/js/order.js
index c76d778..48b56b6 100644
--- a/labs/lab-08/js/order.js
+++ b/labs/lab-08/js/order.js
@@ -1,3 +1,13 @@
+// Экранирование данных перед вставкой в HTML (данные приходят из общего учебного API)
+function esc(value) {
+ return String(value ?? '')
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+}
+
const API_URL = 'https://edu.std-900.ist.mospolytech.ru/labs/api';
const API_KEY = '358a63a5-52ae-4ab0-800b-90f75ce5a5c2';
@@ -101,11 +111,11 @@ function displayOrderDishes() {
function createOrderDishCard(dish) {
return `
-
-
-
${dish.price} руб.
-
${dish.name}
-
${dish.count}
+
+
+
${esc(dish.price)} руб.
+
${esc(dish.name)}
+
${esc(dish.count)}
`;
@@ -177,8 +187,8 @@ function updateOrderSummary() {
Суп
- ${orderDishes.soup.name}
- ${orderDishes.soup.price} руб.
+ ${esc(orderDishes.soup.name)}
+ ${esc(orderDishes.soup.price)} руб.
`;
@@ -197,8 +207,8 @@ function updateOrderSummary() {
Главное блюдо
- ${orderDishes['main-course'].name}
- ${orderDishes['main-course'].price} руб.
+ ${esc(orderDishes['main-course'].name)}
+ ${esc(orderDishes['main-course'].price)} руб.
`;
@@ -217,8 +227,8 @@ function updateOrderSummary() {
Салат
- ${orderDishes.salad.name}
- ${orderDishes.salad.price} руб.
+ ${esc(orderDishes.salad.name)}
+ ${esc(orderDishes.salad.price)} руб.
`;
@@ -237,8 +247,8 @@ function updateOrderSummary() {
Напиток
- ${orderDishes.drink.name}
- ${orderDishes.drink.price} руб.
+ ${esc(orderDishes.drink.name)}
+ ${esc(orderDishes.drink.price)} руб.
`;
@@ -257,8 +267,8 @@ function updateOrderSummary() {
Десерт
- ${orderDishes.dessert.name}
- ${orderDishes.dessert.price} руб.
+ ${esc(orderDishes.dessert.name)}
+ ${esc(orderDishes.dessert.price)} руб.
`;
diff --git a/labs/lab-09/js/menu.js b/labs/lab-09/js/menu.js
index 0e74905..de45037 100644
--- a/labs/lab-09/js/menu.js
+++ b/labs/lab-09/js/menu.js
@@ -1,3 +1,13 @@
+// Экранирование данных перед вставкой в HTML (данные приходят из общего учебного API)
+function esc(value) {
+ return String(value ?? '')
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+}
+
let dishes = [];
const selectedDishes = {
@@ -104,11 +114,11 @@ function displayDishes() {
function createDishCard(dish) {
return `
-
-
-
${dish.price} руб.
-
${dish.name}
-
${dish.count}
+
+
+
${esc(dish.price)} руб.
+
${esc(dish.name)}
+
${esc(dish.count)}
`;
@@ -136,7 +146,7 @@ function selectDish(dish) {
if (previousDish) {
const previousCard = document.querySelector(
- `.dish-card[data-dish="${previousDish.keyword}"]`
+ `.dish-card[data-dish="${esc(previousDish.keyword)}"]`
);
if (previousCard) {
previousCard.classList.remove('selected');
@@ -146,7 +156,7 @@ function selectDish(dish) {
selectedDishes[dish.category] = dish;
const currentCard = document.querySelector(
- `.dish-card[data-dish="${dish.keyword}"]`
+ `.dish-card[data-dish="${esc(dish.keyword)}"]`
);
if (currentCard) {
currentCard.classList.add('selected');
@@ -298,7 +308,7 @@ function restoreSelection() {
const dish = selectedDishes[category];
if (dish) {
const card = document.querySelector(
- `.dish-card[data-dish="${dish.keyword}"]`
+ `.dish-card[data-dish="${esc(dish.keyword)}"]`
);
if (card) {
card.classList.add('selected');
diff --git a/labs/lab-09/js/order.js b/labs/lab-09/js/order.js
index 1d87db0..7970869 100644
--- a/labs/lab-09/js/order.js
+++ b/labs/lab-09/js/order.js
@@ -1,3 +1,13 @@
+// Экранирование данных перед вставкой в HTML (данные приходят из общего учебного API)
+function esc(value) {
+ return String(value ?? '')
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+}
+
const API_URL = 'https://edu.std-900.ist.mospolytech.ru/labs/api';
const API_KEY = '358a63a5-52ae-4ab0-800b-90f75ce5a5c2';
@@ -101,11 +111,11 @@ function displayOrderDishes() {
function createOrderDishCard(dish) {
return `
-
-
-
${dish.price} руб.
-
${dish.name}
-
${dish.count}
+
+
+
${esc(dish.price)} руб.
+
${esc(dish.name)}
+
${esc(dish.count)}
`;
@@ -177,8 +187,8 @@ function updateOrderSummary() {
Суп
- ${orderDishes.soup.name}
- ${orderDishes.soup.price} руб.
+ ${esc(orderDishes.soup.name)}
+ ${esc(orderDishes.soup.price)} руб.
`;
@@ -197,8 +207,8 @@ function updateOrderSummary() {
Главное блюдо
- ${orderDishes['main-course'].name}
- ${orderDishes['main-course'].price} руб.
+ ${esc(orderDishes['main-course'].name)}
+ ${esc(orderDishes['main-course'].price)} руб.
`;
@@ -217,8 +227,8 @@ function updateOrderSummary() {
Салат
- ${orderDishes.salad.name}
- ${orderDishes.salad.price} руб.
+ ${esc(orderDishes.salad.name)}
+ ${esc(orderDishes.salad.price)} руб.
`;
@@ -237,8 +247,8 @@ function updateOrderSummary() {
Напиток
- ${orderDishes.drink.name}
- ${orderDishes.drink.price} руб.
+ ${esc(orderDishes.drink.name)}
+ ${esc(orderDishes.drink.price)} руб.
`;
@@ -257,8 +267,8 @@ function updateOrderSummary() {
Десерт
- ${orderDishes.dessert.name}
- ${orderDishes.dessert.price} руб.
+ ${esc(orderDishes.dessert.name)}
+ ${esc(orderDishes.dessert.price)} руб.
`;
diff --git a/labs/lab-09/js/orders.js b/labs/lab-09/js/orders.js
index 874b646..804553c 100644
--- a/labs/lab-09/js/orders.js
+++ b/labs/lab-09/js/orders.js
@@ -1,3 +1,13 @@
+// Экранирование данных перед вставкой в HTML (данные приходят из общего учебного API)
+function esc(value) {
+ return String(value ?? '')
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"')
+ .replace(/'/g, ''');
+}
+
const API_URL = 'https://edu.std-900.ist.mospolytech.ru/labs/api';
const API_KEY = '358a63a5-52ae-4ab0-800b-90f75ce5a5c2';
@@ -91,16 +101,16 @@ function createOrderCard(order, number) {
const deliveryTime = getDeliveryTime(order);
return `
-