Skip to content

Commit 50becb0

Browse files
committed
[push] Trim URLs in create message dialog & on backend side
1 parent c4e43f9 commit 50becb0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

plugins/push/frontend/public/javascripts/component.push.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ window.component('push', function(push) {
100100
this.sent = m.prop(data.sent);
101101
this.sound = vprop(data.sound, function(v){ return !!v; }, t('pu.po.tab2.extras.sound.invalid'));
102102
this.badge = vprop(data.badge, function(v){ return v === undefined || ((v + '') === (parseInt(v) + '') && parseInt(v) >= 0); }, t('pu.po.tab2.extras.badge.invalid'));
103-
this.url = vprop(data.url, function(v){ return v && URL_REGEXP.test(v); }, t('pu.po.tab2.extras.url.invalid'));
103+
this.url = vprop(data.url, function(v){ return v && URL_REGEXP.test(v) && v[0] !== ' ' && v[v.length - 1] !== ' '; }, t('pu.po.tab2.extras.url.invalid'));
104104
this.data = vprop(typeof data.data === 'object' ? JSON.stringify(data.data) : data.data, function(v){
105105
try {
106106
var o = window.jsonlite.parse(v);
@@ -224,6 +224,9 @@ window.component('push', function(push) {
224224
var prop = m.prop(),
225225
f = function(){
226226
if (arguments.length) {
227+
if (arguments[0]) {
228+
arguments[0] = arguments[0].trim();
229+
}
227230
f.valid = false;
228231
prop(arguments[0]);
229232

@@ -403,9 +406,15 @@ window.component('push', function(push) {
403406
obj.sound = this.sound();
404407
obj.badge = this.badge();
405408
obj.url = this.url();
409+
if (obj.url) {
410+
obj.url = obj.url.trim();
411+
}
406412
obj.source = 'dash';
407413
obj.buttons = parseInt(this.buttons());
408414
obj.media = this.media();
415+
if (obj.media) {
416+
obj.media = obj.media.trim();
417+
}
409418
obj.autoOnEntry = this.autoOnEntry();
410419
obj.autoCancelTrigger = this.autoCancelTrigger();
411420
obj.autoCohorts = this.autoCohorts();

plugins/push/frontend/public/javascripts/component.push.popup.js

+3
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ window.component('push.popup', function(popup) {
367367
k = (locale || activeLocale()) + (index === undefined ? (push.C.S + key) : (push.C.S + index + push.C.S + key));
368368

369369
if (arguments.length) {
370+
if (v && key === 'l') {
371+
v = v.trim();
372+
}
370373
message.messagePerLocale()[k] = v;
371374
}
372375

0 commit comments

Comments
 (0)