Skip to content

Commit 7b508fe

Browse files
committed
Fix incomplete regex replacements
1 parent 8e23bed commit 7b508fe

7 files changed

Lines changed: 29 additions & 12 deletions

File tree

DNN Platform/JavaScript Libraries/DnnPlugins/dnn.jquery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2683,7 +2683,7 @@
26832683
var profileImagePath = dnn.getVar("sf_siteRoot", "/") + 'DnnImageHandler.ashx?mode=securefile&fileId=' + data.result.FileId + '&MaxWidth=180&MaxHeight=150';
26842684
img.src = profileImagePath;
26852685

2686-
var fileName = data.result.FilePath.replace('\\', '/');
2686+
var fileName = data.result.FilePath.replace(/\\/g, '/');
26872687
if (fileName.indexOf('/') > -1) {
26882688
fileName = fileName.split('/')[fileName.split('/').length - 1];
26892689
}

DNN Platform/Modules/CoreMessaging/Scripts/CoreMessaging.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
function getQuerystring(key, default_) {
3434
if (default_ == null) default_ = "";
35-
key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
35+
key = key.replace(/\[/g, "\\\[").replace(/]/g, "\\\]");
3636
var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
3737
var qs = regex.exec(window.location.href);
3838
if (qs == null)

DNN Platform/Modules/Journal/Scripts/journal.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,13 +481,22 @@ function pluginInit() {
481481
} else {
482482
data.itemData = '';
483483
}
484-
if ((data.text == '' && data.itemData == '') || data.text == '%3Cbr%3E') {
484+
if ((!data.text && !data.itemData) || data.text === '%3Cbr%3E') {
485485
return false;
486486
}
487487
//Check for a value
488488
var tmpValue = $content.val();
489-
tmpValue = tmpValue.replace(/<(?:.|\n)*?>/gm, '').replace(/\s+/g, '').replace(/&nbsp;/g,'');
490-
if (tmpValue == '' && data.itemData == '') {
489+
while (/<(?:.|\n)*?>/gm.test(tmpValue)) {
490+
tmpValue = tmpValue.replace(/<(?:.|\n)*?>/gm, '');
491+
}
492+
while (/\s+/g.test(tmpValue)) {
493+
tmpValue = tmpValue.replace(/\s+/g, '');
494+
}
495+
while (/&nbsp;/g.test(tmpValue)) {
496+
tmpValue = tmpValue.replace(/&nbsp;/g, '');
497+
}
498+
499+
if (tmpValue === '' && data.itemData === '') {
491500
return false;
492501
}
493502
data.mentions = $content.data("mentions");

DNN Platform/Modules/Journal/Scripts/journalcomments.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,19 @@
6565
data.Comment = encodeURIComponent($textarea.val());
6666
data.mentions = $textarea.data("mentions");
6767
var tmpValue = $textarea.val();
68-
tmpValue = tmpValue.replace(/<(?:.|\n)*?>/gm, '').replace(/\s+/g, '').replace(/&nbsp;/g, '');
69-
if (tmpValue == '') {
68+
while (/<(?:.|\n)*?>/gm.test(tmpValue)) {
69+
tmpValue = tmpValue.replace(/<(?:.|\n)*?>/gm, '');
70+
}
71+
while (/\s+/g.test(tmpValue)) {
72+
tmpValue = tmpValue.replace(/\s+/g, '');
73+
}
74+
while (/&nbsp;/g.test(tmpValue)) {
75+
tmpValue = tmpValue.replace(/&nbsp;/g, '');
76+
}
77+
if (tmpValue === '') {
7078
return false;
7179
}
72-
if (data.Comment == '' || data.Comment == '%3Cbr%3E') {
80+
if (!data.Comment || data.Comment === '%3Cbr%3E') {
7381
return false;
7482
}
7583
Post('CommentSave', data, commentComplete, jid);

DNN Platform/Providers/HtmlEditorProviders/DNNConnect.CKE/js/ckeditor/4.18.0/plugins/dnnpages/plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,11 @@
222222
};
223223

224224
function unescapeSingleQuote( str ) {
225-
return str.replace( /\\'/g, '\'' );
225+
return str.replace( /\\'/g, '\'' ).replace(/\\\\/g, '\\');
226226
}
227227

228228
function escapeSingleQuote( str ) {
229-
return str.replace( /'/g, '\\$&' );
229+
return str.replace( /'/g, '\\$&' ).replace(/\\/g, '\\\\');
230230
}
231231

232232
function protectEmailAddressAsEncodedString( address ) {

DNN Platform/Website/Resources/Shared/scripts/dnn.jquery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2677,7 +2677,7 @@
26772677
var profileImagePath = dnn.getVar("sf_siteRoot", "/") + 'DnnImageHandler.ashx?mode=securefile&fileId=' + data.result.FileId + '&MaxWidth=180&MaxHeight=150';
26782678
img.src = profileImagePath;
26792679

2680-
var fileName = data.result.FilePath.replace('\\', '/');
2680+
var fileName = data.result.FilePath.replace(/\\/g, '/');
26812681
if (fileName.indexOf('/') > -1) {
26822682
fileName = fileName.split('/')[fileName.split('/').length - 1];
26832683
}

Dnn.AdminExperience/ClientSide/Prompt.Web/src/utils/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function sort(items, column, order) {
2424
export function formatLabel(input) {
2525
if (typeof input === "string") {
2626
// format camelcase and remove Is from labels
27-
let output = input.replace("$", "").replace(/^(Is)(.+)/i, "$2");
27+
let output = input.replace(/$/g, "").replace(/^(Is)(.+)/i, "$2");
2828
output = output.match(/[A-Z][a-z]+/g).join(" "); // rudimentary but should handle normal Camelcase
2929
return output;
3030
}

0 commit comments

Comments
 (0)