Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
merge-requests/55/merge
Julien Veyssier 2021-06-25 15:38:52 +02:00
parent 9f1c0d64bc
commit d16c4b294f
No known key found for this signature in database
GPG Key ID: 4141FEE162030638
5 changed files with 161 additions and 146 deletions

1
.gitignore vendored 100644
View File

@ -0,0 +1 @@
.idea

View File

@ -1,125 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<database>
<name>*dbname*</name>
<create>true</create>
<overwrite>false</overwrite>
<charset>utf8</charset>
<table>
<name>*dbprefix*gpxedit_tile_servers</name>
<declaration>
<field>
<name>id</name>
<type>integer</type>
<default>0</default>
<notnull>true</notnull>
<autoincrement>1</autoincrement>
<length>4</length>
</field>
<field>
<name>user</name>
<type>text</type>
<notnull>true</notnull>
<length>64</length>
</field>
<field>
<name>type</name>
<type>text</type>
<default>tile</default>
<notnull>true</notnull>
<length>20</length>
</field>
<field>
<name>servername</name>
<type>text</type>
<notnull>true</notnull>
<length>300</length>
</field>
<field>
<name>url</name>
<type>text</type>
<notnull>true</notnull>
<length>300</length>
</field>
<field>
<name>format</name>
<type>text</type>
<notnull>true</notnull>
<default>image/jpeg</default>
<length>300</length>
</field>
<field>
<name>layers</name>
<type>text</type>
<notnull>true</notnull>
<default></default>
<length>300</length>
</field>
<field>
<name>version</name>
<type>text</type>
<notnull>true</notnull>
<default>1.1.1</default>
<length>30</length>
</field>
<field>
<name>opacity</name>
<type>text</type>
<notnull>true</notnull>
<default>0.4</default>
<length>10</length>
</field>
<field>
<name>transparent</name>
<type>text</type>
<notnull>true</notnull>
<default>true</default>
<length>10</length>
</field>
<field>
<name>minzoom</name>
<type>integer</type>
<notnull>true</notnull>
<default>1</default>
<length>4</length>
</field>
<field>
<name>maxzoom</name>
<type>integer</type>
<notnull>true</notnull>
<default>18</default>
<length>4</length>
</field>
<field>
<name>attribution</name>
<type>text</type>
<notnull>true</notnull>
<default>???</default>
<length>300</length>
</field>
</declaration>
</table>
<table>
<name>*dbprefix*gpxedit_options</name>
<declaration>
<field>
<name>id</name>
<type>integer</type>
<default>0</default>
<notnull>true</notnull>
<autoincrement>1</autoincrement>
<length>4</length>
</field>
<field>
<name>user</name>
<type>text</type>
<notnull>true</notnull>
<length>64</length>
</field>
<field>
<name>jsonvalues</name>
<type>clob</type>
<notnull>true</notnull>
</field>
</declaration>
</table>
</database>

View File

@ -3,7 +3,7 @@
<id>gpxedit</id>
<name>GpxEdit</name>
<summary> </summary><description> </description>
<version>0.0.13</version>
<version>0.0.14</version>
<licence>agpl</licence>
<author>Julien Veyssier</author>
<namespace>GpxEdit</namespace>
@ -23,7 +23,7 @@
<database min-version="9.4">pgsql</database>
<database>sqlite</database>
<database min-version="5.5">mysql</database>
<nextcloud min-version="14" max-version="19"/>
<nextcloud min-version="14" max-version="23"/>
</dependencies>
<settings>
<admin>OCA\GpxEdit\Settings\Admin</admin>

View File

@ -178,6 +178,17 @@
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
function escapeHtml(text) {
const map = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#039;',
}
return text.replace(/[&<>"']/g, (m) => { return map[m] })
}
function load_map() {
// change meta to send referrer
// usefull for IGN tiles authentication !
@ -628,11 +639,11 @@
gpxText = gpxText + '<metadata>\n <time>' + now_utc_str + '</time>\n';
var trackName = $('#tracknameinput').val();
if (trackName) {
gpxText = gpxText + ' <name>' + escapeHTML(trackName) + '</name>\n';
gpxText = gpxText + ' <name>' + escapeHtml(trackName) + '</name>\n';
}
var fileDesc = $('#desctext').val();
if (fileDesc) {
gpxText = gpxText + ' <desc>' + escapeHTML(fileDesc) + '</desc>\n';
gpxText = gpxText + ' <desc>' + escapeHtml(fileDesc) + '</desc>\n';
}
var linkurl = $('#linkurlinput').val();
if (linkurl) {
@ -640,7 +651,7 @@
var linktext = $('#linktextinput').val();
if (linktext) {
gpxText = gpxText + ' <text>' + escapeHTML(linktext) + '</text>\n';
gpxText = gpxText + ' <text>' + escapeHtml(linktext) + '</text>\n';
}
gpxText = gpxText + ' </link>\n';
}
@ -720,7 +731,7 @@
alt = layer._latlng.alt;
gpxText = gpxText + ' <wpt lat="' + lat + '" lon="' + lng + '">\n';
if (name) {
gpxText = gpxText + ' <name>' + escapeHTML(name) + '</name>\n';
gpxText = gpxText + ' <name>' + escapeHtml(name) + '</name>\n';
}
else{
gpxText = gpxText + ' <name></name>\n';
@ -729,16 +740,16 @@
gpxText = gpxText + ' <ele>' + alt + '</ele>\n';
}
if (linkText && linkUrl) {
gpxText = gpxText + ' <link href="' + escapeHTML(linkUrl) + '"><text>' + escapeHTML(linkText) + '</text></link>\n';
gpxText = gpxText + ' <link href="' + escapeHtml(linkUrl) + '"><text>' + escapeHtml(linkText) + '</text></link>\n';
}
if (comment) {
gpxText = gpxText + ' <cmt>' + escapeHTML(comment) + '</cmt>\n';
gpxText = gpxText + ' <cmt>' + escapeHtml(comment) + '</cmt>\n';
}
if (symbol) {
gpxText = gpxText + ' <sym>' + symbol + '</sym>\n';
}
if (description) {
gpxText = gpxText + ' <desc>' + escapeHTML(description) + '</desc>\n';
gpxText = gpxText + ' <desc>' + escapeHtml(description) + '</desc>\n';
}
if (time) {
gpxText = gpxText + ' <time>' + time + '</time>\n';
@ -748,19 +759,19 @@
else if(!layer.type || layer.type === 'track') {
gpxText = gpxText + ' <trk>\n';
if (name) {
gpxText = gpxText + ' <name>' + escapeHTML(name) + '</name>\n';
gpxText = gpxText + ' <name>' + escapeHtml(name) + '</name>\n';
}
else{
gpxText = gpxText + ' <name></name>\n';
}
if (comment) {
gpxText = gpxText + ' <cmt>' + escapeHTML(comment) + '</cmt>\n';
gpxText = gpxText + ' <cmt>' + escapeHtml(comment) + '</cmt>\n';
}
if (linkText && linkUrl) {
gpxText = gpxText + ' <link href="' + escapeHTML(linkUrl) + '"><text>' + escapeHTML(linkText) + '</text></link>\n';
gpxText = gpxText + ' <link href="' + escapeHtml(linkUrl) + '"><text>' + escapeHtml(linkText) + '</text></link>\n';
}
if (description) {
gpxText = gpxText + ' <desc>' + escapeHTML(description) + '</desc>\n';
gpxText = gpxText + ' <desc>' + escapeHtml(description) + '</desc>\n';
}
gpxText = gpxText + ' <trkseg>\n';
for (i = 0; i < layer._latlngs.length; i++) {
@ -782,19 +793,19 @@
else if(layer.type === 'route') {
gpxText = gpxText + ' <rte>\n';
if (name) {
gpxText = gpxText + ' <name>' + escapeHTML(name) + '</name>\n';
gpxText = gpxText + ' <name>' + escapeHtml(name) + '</name>\n';
}
else{
gpxText = gpxText + ' <name></name>\n';
}
if (comment) {
gpxText = gpxText + ' <cmt>' + escapeHTML(comment) + '</cmt>\n';
gpxText = gpxText + ' <cmt>' + escapeHtml(comment) + '</cmt>\n';
}
if (linkText && linkUrl) {
gpxText = gpxText + ' <link href="' + escapeHTML(linkUrl) + '"><text>' + escapeHTML(linkText) + '</text></link>\n';
gpxText = gpxText + ' <link href="' + escapeHtml(linkUrl) + '"><text>' + escapeHtml(linkText) + '</text></link>\n';
}
if (description) {
gpxText = gpxText + ' <desc>' + escapeHTML(description) + '</desc>\n';
gpxText = gpxText + ' <desc>' + escapeHtml(description) + '</desc>\n';
}
for (i = 0; i < layer._latlngs.length; i++) {
lat = layer._latlngs[i].lat;
@ -1294,9 +1305,9 @@
}).done(function (response) {
if (response.done) {
$('#'+type+'serverlist ul').prepend(
'<li style="display:none;" servername="' + escapeHTML(sname) +
'" title="' + escapeHTML(surl) + '">' +
escapeHTML(sname) + ' <button>' +
'<li style="display:none;" servername="' + escapeHtml(sname) +
'" title="' + escapeHtml(surl) + '">' +
escapeHtml(sname) + ' <button>' +
'<i class="fa fa-trash" aria-hidden="true" style="color:red;"></i> ' +
t('gpxedit', 'Delete') +
'</button></li>'

View File

@ -0,0 +1,128 @@
<?php
declare(strict_types=1);
namespace OCA\GpxEdit\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version000014Date20210625132243 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('gpxedit_tile_servers')) {
$table = $schema->createTable('gpxedit_tile_servers');
$table->addColumn('id', 'integer', [
'autoincrement' => true,
'notnull' => true,
'length' => 4,
]);
$table->addColumn('user', 'string', [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('type', 'string', [
'notnull' => true,
'length' => 20,
'default' => 'tile',
]);
$table->addColumn('servername', 'string', [
'notnull' => true,
'length' => 300,
]);
$table->addColumn('url', 'string', [
'notnull' => true,
'length' => 300,
]);
$table->addColumn('format', 'string', [
'notnull' => true,
'length' => 300,
'default' => 'image/jpeg',
]);
$table->addColumn('layers', 'string', [
'notnull' => true,
'length' => 300,
'default' => '',
]);
$table->addColumn('version', 'string', [
'notnull' => true,
'length' => 30,
'default' => '1.1.1',
]);
$table->addColumn('opacity', 'string', [
'notnull' => true,
'length' => 10,
'default' => '0.4',
]);
$table->addColumn('transparent', 'string', [
'notnull' => true,
'length' => 10,
'default' => 'true',
]);
$table->addColumn('minzoom', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 1,
]);
$table->addColumn('maxzoom', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 18,
]);
$table->addColumn('attribution', 'string', [
'notnull' => true,
'length' => 300,
'default' => '???',
]);
$table->setPrimaryKey(['id']);
}
if (!$schema->hasTable('gpxedit_options')) {
$table = $schema->createTable('gpxedit_options');
$table->addColumn('id', 'integer', [
'autoincrement' => true,
'notnull' => true,
'length' => 4,
]);
$table->addColumn('user', 'string', [
'notnull' => true,
'length' => 64,
]);
$table->addColumn('jsonvalues', 'text', [
'notnull' => true,
]);
$table->setPrimaryKey(['id']);
}
return $schema;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
}
}