Skip to content

Commit

Permalink
Fix encoding test entities
Browse files Browse the repository at this point in the history
  • Loading branch information
Floofies committed Jul 12, 2021
1 parent 57bd0d4 commit 07740dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion new-stations/xmlGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ const kbHead = `<?xml version="1.0" encoding="ISO-8859-1"?><kb:Kerbango xmlns:kb
const kbRes = `<kb:results>`;
const kbResFoot = `</kb:results>`;
const kbFoot = `</kb:Kerbango>`;
const terminals = {
"&": "&amp;",
"?": "&#63;",
"<": "&lt;",
">": "&gt;",
";": "&#59;",
"=": "&#61;",
"'": "&#39;",
"\"": "&#34;"
};
function htmlEntity(terminal) {
return terminals[terminal];
}
function htmlEntities(str) {
return str.replace(/[&?<>;=]/g, htmlEntity);
}
const charStr = "!'(),-./0123456789:;<=>?@ABCDEFGHIJKLMNOPRSTUVWXY^_abcdefghijklmnopqrstuvwxyz|éö–’%QZ[ßàäçèôúüŽ‘“„…€*+]ÖÜáãíóı™´Äêðñ𜡔°É​—台四港第電香~ş«»`{}ûÇÈ║″ÁÙâëîùąęłńśżΠήίαγδεηθικλμνορτφωύآأابةثجحخدرزسشصعغقلمنوىي♫ΒÎåčįİšųžАБВЕИКЛНПСЧабвгдежзийклмнопрстуфцчшья一三二五數普碼話通ÍÚïòõćđƯЈЗРЦЮхыэюҥằếệịọốộớừÀØæøě";
const genres = [
{ id: "3", name: "90's Hits" },
Expand Down Expand Up @@ -69,7 +85,7 @@ async function generateRecords(kbJSON) {
const emptyStr = kbHead + kbRes + kbResFoot + kbFoot;
fs.writeFile("./empty.xml", converter.convert(emptyStr, "UTF-8"), "latin1");
console.log("Generating encoding-test.xml ...");
const testStr = kbHead + kbRes + kbTestStation("Latin1DevEncodingTest", charStr) + kbResFoot + kbFoot;
const testStr = kbHead + kbRes + kbTestStation("Latin1DevEncodingTest", htmlEntities(charStr)) + kbResFoot + kbFoot;
fs.writeFile("./encoding-test.xml", converter.convert(testStr, "UTF-8"), "latin1");
console.log("Generating genres.xml ...");
var menuStr = kbHead + kbRes;
Expand Down
2 changes: 1 addition & 1 deletion xml/encoding-test.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="ISO-8859-1"?><kb:Kerbango xmlns:kb="http://www.kerbango.com/xml"><kb:results><kb:station_record><kb:station>Latin1DevEncodingTest</kb:station><kb:description>foobar</kb:description><kb:long_description>!'(),-./0123456789:;<=>?@ABCDEFGHIJKLMNOPRSTUVWXY^_abcdefghijklmnopqrstuvwxyz|éö-´%QZ[ßàäçèôúüZ`""...EUR*+]ÖÜáãíóiTM´Äêðñgoe¡"°É-~s«»`{}ûÇÈ´´ÁÙâëîùael´n´szÎåciIsuzÍÚïòõ´cdÀØæøe</kb:long_description><kb:num_users>1</kb:num_users><kb:max_users>100</kb:max_users><kb:station_url_record><kb:url>http://listen.radionomy.com/lovejazzflorida.m3u</kb:url><kb:status_code>200</kb:status_code><kb:bandwidth_kbps>128</kb:bandwidth_kbps></kb:station_url_record></kb:station_record></kb:results></kb:Kerbango>
<?xml version="1.0" encoding="ISO-8859-1"?><kb:Kerbango xmlns:kb="http://www.kerbango.com/xml"><kb:results><kb:station_record><kb:station>Latin1DevEncodingTest</kb:station><kb:description>foobar</kb:description><kb:long_description>!'(),-./0123456789:&#59;&lt;&#61;&gt;&#63;@ABCDEFGHIJKLMNOPRSTUVWXY^_abcdefghijklmnopqrstuvwxyz|éö-´%QZ[ßàäçèôúüZ`""...EUR*+]ÖÜáãíóiTM´Äêðñgoe¡"°É-~s«»`{}ûÇÈ´´ÁÙâëîùael´n´szÎåciIsuzÍÚïòõ´cdÀØæøe</kb:long_description><kb:num_users>1</kb:num_users><kb:max_users>100</kb:max_users><kb:station_url_record><kb:url>http://listen.radionomy.com/lovejazzflorida.m3u</kb:url><kb:status_code>200</kb:status_code><kb:bandwidth_kbps>128</kb:bandwidth_kbps></kb:station_url_record></kb:station_record></kb:results></kb:Kerbango>

0 comments on commit 07740dc

Please sign in to comment.