Cap sound and stream URL fields at 2048 chars
This commit is contained in:
@@ -44,7 +44,7 @@ EFFECT_OPTIONS: tuple[str, ...] = ("reverb", "echo", "flanger", "high_pass", "lo
|
||||
|
||||
PROPERTY_METADATA: dict[str, dict[str, object]] = {
|
||||
"title": {"valueType": "text", "tooltip": "Display name spoken and shown for this item.", "maxLength": 80},
|
||||
"streamUrl": {"valueType": "text", "tooltip": "Audio stream URL used by this radio."},
|
||||
"streamUrl": {"valueType": "text", "tooltip": "Audio stream URL used by this radio.", "maxLength": 2048},
|
||||
"enabled": {"valueType": "boolean", "tooltip": "Turns playback on or off for this radio."},
|
||||
"mediaVolume": {
|
||||
"valueType": "number",
|
||||
@@ -75,6 +75,8 @@ def validate_update(item: WorldItem, next_params: dict) -> dict:
|
||||
"""Validate and normalize radio params."""
|
||||
|
||||
stream_url = str(next_params.get("streamUrl", "")).strip()
|
||||
if len(stream_url) > 2048:
|
||||
raise ValueError("streamUrl must be 2048 characters or less.")
|
||||
previous_stream_url = str(item.params.get("streamUrl", "")).strip()
|
||||
next_params["streamUrl"] = stream_url
|
||||
|
||||
|
||||
@@ -81,8 +81,16 @@ PROPERTY_METADATA: dict[str, dict[str, object]] = {
|
||||
"tooltip": "Amount for emit effect.",
|
||||
"range": {"min": 0, "max": 100, "step": 0.1},
|
||||
},
|
||||
"useSound": {"valueType": "sound", "tooltip": "Sound played on use. Filename assumes sounds folder, or use full URL."},
|
||||
"emitSound": {"valueType": "sound", "tooltip": "Looping emitted sound. Filename assumes sounds folder, or use full URL."},
|
||||
"useSound": {
|
||||
"valueType": "sound",
|
||||
"tooltip": "Sound played on use. Filename assumes sounds folder, or use full URL.",
|
||||
"maxLength": 2048,
|
||||
},
|
||||
"emitSound": {
|
||||
"valueType": "sound",
|
||||
"tooltip": "Looping emitted sound. Filename assumes sounds folder, or use full URL.",
|
||||
"maxLength": 2048,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -169,6 +177,10 @@ def validate_update(item: WorldItem, next_params: dict) -> dict:
|
||||
|
||||
next_params["useSound"] = _normalize_sound_value(next_params.get("useSound", item.params.get("useSound", "")))
|
||||
next_params["emitSound"] = _normalize_sound_value(next_params.get("emitSound", item.params.get("emitSound", "")))
|
||||
if len(next_params["useSound"]) > 2048:
|
||||
raise ValueError("useSound must be 2048 characters or less.")
|
||||
if len(next_params["emitSound"]) > 2048:
|
||||
raise ValueError("emitSound must be 2048 characters or less.")
|
||||
return next_params
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user