summaryrefslogtreecommitdiff
path: root/backend.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-03-14 15:20:59 +0300
committerAndrew Dolgov <[email protected]>2021-03-14 15:20:59 +0300
commit50ddfaf18b0b9aae7768facb39a3314d23961835 (patch)
treec87546cbc0c264f5a920f3bc16706387928fc425 /backend.php
parentac851686875ec8d2478f768fb1ec3b86a99961e7 (diff)
sanitize retrieved wiktionary content (just in case)
Diffstat (limited to 'backend.php')
-rw-r--r--backend.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/backend.php b/backend.php
index 0cbd6f4..9678fab 100644
--- a/backend.php
+++ b/backend.php
@@ -249,7 +249,13 @@
$url = "https://en.wiktionary.org/w/api.php?titles=${query}&action=query&prop=extracts&format=json&exlimit=1";
if ($resp = file_get_contents($url)) {
- print $resp;
+ $resp = json_decode($resp, true);
+
+ foreach ($resp['query']['pages'] as &$page) {
+ $page['extract'] = Sanitizer::sanitize($page['extract']);
+ }
+
+ print json_encode($resp);
}
break;