Skip to content

Commit

Permalink
Merge branch 'v3' of https://github.com/craftcms/cms into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	src/web/assets/cp/dist/cp.js
#	src/web/assets/cp/dist/cp.js.map
#	src/web/assets/cp/src/js/Craft.js
#	src/web/assets/garnish/dist/garnish.js
#	src/web/assets/garnish/dist/garnish.js.map
#	src/web/assets/routes/dist/routes.js
#	src/web/assets/routes/dist/routes.js.map
#	src/web/assets/routes/src/routes.js
  • Loading branch information
brandonkelly committed May 23, 2023
2 parents 3a2158b + ddc6e4e commit 4f55d43
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
- Removed the OAuth 2.0 Client library, as it’s no longer used in core.
- Fixed a bug where activation emails sent to newly-created users could link to the front-end site, if they were granted control panel access via a user group. ([#13204](https://github.com/craftcms/cms/issues/13204))
- Fixed a bug where “Required” lightswitch labels within field layout designers’ field settings slideouts weren’t getting translated. ([#13230](https://github.com/craftcms/cms/issues/13230))
- Fixed a bug where Date fields could display the wrong date. ([#13233](https://github.com/craftcms/cms/issues/13233))
- Deprecated the `Craft.startsWith()` JavaScript method. `String.prototype.startsWith()` should be used instead.
- Fixed two XSS vulnerabilities.

## 4.4.11 - 2023-05-15
Expand Down
2 changes: 1 addition & 1 deletion src/templates/_includes/forms/date.twig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
autocomplete: false,
size: 10,
placeholder: ' ',
value: value ? value|date(isMobile ? 'Y-m-d' : 'short') : '',
value: value ? value|date(isMobile ? 'Y-m-d' : 'short', false) : '',
inputAttributes: {
aria: {
label: isDateTime ? 'Date'|t('app') : false,
Expand Down
2 changes: 1 addition & 1 deletion src/templates/_includes/forms/time.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
autocomplete: false,
size: 10,
placeholder: ' ',
value: value ? value|time(isMobile ? 'H:i' : 'short') : '',
value: value ? value|time(isMobile ? 'H:i' : 'short', false) : '',
inputAttributes: {
aria: {
label: isDateTime ? 'Time'|t('app') : false,
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions src/web/assets/cp/src/js/BaseElementIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,14 @@ Craft.BaseElementIndex = Garnish.Base.extend(
}
}

if (!sourceKey) {
// If we couldn't resolve a default source, clear out the defaultSource and defaultSourcePath
// settings, as defaultSourcePath is expected to be relative to defaultSource
// (https://github.com/craftcms/cms/issues/13072)
this.settings.defaultSource = null;
this.settings.defaultSourcePath = null;
}

return sourceKey ?? this.instanceState.selectedSource;
},

Expand All @@ -605,11 +613,7 @@ Craft.BaseElementIndex = Garnish.Base.extend(
if (
this.settings.defaultSourcePath !== null &&
this.settings.defaultSourcePath[0] !== undefined &&
this.settings.defaultSourcePath[0].canView === true &&
((this.sourcePath.length > 0 &&
this.sourcePath[0].handle ===
this.settings.defaultSourcePath[0].handle) ||
this.sourcePath.length === 0)
this.settings.defaultSourcePath[0].canView === true
) {
return this.settings.defaultSourcePath;
} else {
Expand Down
31 changes: 30 additions & 1 deletion src/web/assets/cp/src/js/Craft.js
Original file line number Diff line number Diff line change
Expand Up @@ -1464,9 +1464,38 @@ $.extend(Craft, {
* @param {string} str
* @param {string} substr
* @returns {boolean}
* @deprecated String.prototype.endsWith() should be used instead
*/
startsWith: function (str, substr) {
return str.substring(0, substr.length) === substr;
return str.startsWith(substr);
},

/**
* Ensures a string starts with another string.
*
* @param {string} str
* @param {string} substr
* @return {string}
*/
ensureStartsWith: function (str, substr) {
if (!str.startsWith(substr)) {
str = substr + str;
}
return str;
},

/**
* Ensures a string ends with another string.
*
* @param {string} str
* @param {string} substr
* @return {string}
*/
ensureEndsWith: function (str, substr) {
if (!str.endsWith(substr)) {
str += substr;
}
return str;
},

/**
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/garnish/dist/garnish.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/garnish/dist/garnish.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion src/web/assets/garnish/src/BaseDrag.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,11 @@ export default Base.extend(

if (typeof this.settings.handle === 'string') {
// https://github.com/craftcms/cms/issues/12896
return $(this.settings.handle, item).first();
const selector = this.settings.handle
.split(',')
.map((s) => Craft.ensureEndsWith(Craft.trim(s), ':first'))
.join(',');
return $(selector, item);
}

if (typeof this.settings.handle === 'function') {
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/routes/dist/routes.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/routes/dist/routes.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/web/assets/routes/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ import './routes.scss';
val = Craft.ltrim(val, '/');

// Make sure the first element isn’t using the action/control panel trigger
if (Craft.startsWith(val, Craft.actionTrigger + '/')) {
if (val.startsWith(`${Craft.actionTrigger}/`)) {
this.addUriError(
Craft.t(
'app',
Expand All @@ -406,7 +406,7 @@ import './routes.scss';
return;
} else if (
Craft.cpTrigger &&
Craft.startsWith(val, Craft.cpTrigger + '/')
val.startsWith(`${Craft.cpTrigger}/`)
) {
this.addUriError(
Craft.t(
Expand Down

0 comments on commit 4f55d43

Please sign in to comment.