ZORALab / Hestia

One Peaceful Frontend+Backend Software Library Suite.
https://hestia.zoralab.com
Other
19 stars 1 forks source link

List Data Sanitizer Has Improper Slice to Dict Key Type Conversion #82

Closed hollowaykeanho closed 1 year ago

hollowaykeanho commented 1 year ago

Description

Please provide a short description of what you have encountered below.

During a slice to dictionary conversion, the integer key is not properly converted into string type causing a crash when the API is used. This is found in List Data Sanitizer API.

Expected Behavior

Please specify the expected behavior of your usage below.

This patch is applied:

--- a/sites/themes/hestiaHUGO/layouts/partials/Hestia/functions/data/list/Init
+++ b/sites/themes/hestiaHUGO/layouts/partials/Hestia/functions/data/list/Init
@@ -41,7 +41,7 @@ specific language governing permissions and limitations under the License.
 {{- if partial "Hestia/functions/data/list/IsSlice" $ret -}}
        {{- $dataList = dict -}}
        {{- range $i, $v := $ret -}}
-               {{- $dataList = merge $dataList (dict $i $v) -}}
+               {{- $dataList = merge $dataList (dict (string $i) $v) -}}
        {{- end -}}
 {{- else if partial "Hestia/functions/data/list/IsMap" $ret -}}
        {{- $dataList = $ret -}}

Current Behavior

Please specify the current behavior of software below.

Crashes if slice is given and the sanitizer attempts to convert it to dictionary.

Steps to Reproduce (COMPULSORY)

Please specify all the steps required to re-produce the problem.

Attachments

Please drag and drop the necessary data files (e.g. screenshot, logs, etc)
below.
hollowaykeanho commented 1 year ago

Will be implemented using the new API system in HestiaHUGO instead of backporting.

hollowaykeanho commented 1 year ago

Implemented in 04769b356e17b18b7ae5fe33adaabe4271bb72f1

hollowaykeanho commented 1 year ago

Released in version v.1.2.0.