Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit c4a3a28

Browse files
Merge pull request #2030 from livecode/bugfix-21809
Ensure stack name cannot be set to a number via the Project Browser
2 parents 77f21f3 + 0c4856b commit c4a3a28

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
lines changed

Toolset/libraries/revidelibrary.8.livecodescript

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5111,6 +5111,27 @@ private on __setPropertyOfObject pObject, pProperty, pValue
51115111

51125112
end __setPropertyOfObject
51135113

5114+
function ideCheckStackName pName
5115+
if char 1 to 3 of pName is "rev" then
5116+
answer warning revIDELocalise("Using rev in the first three characters of a stack name is reserved for use by the LiveCode development environment and advanced users creating Plug-ins. If you use these characters, your stack may not behave as expected.") with revIDELocalise("OK") and revIDELocalise("Cancel")
5117+
if it is revIDELocalise("Cancel") then
5118+
return false
5119+
end if
5120+
end if
5121+
if pName is a number then
5122+
beep
5123+
answer error revIDELocalise("You cannot set the name of a stack to a number.")
5124+
return false
5125+
end if
5126+
if pName contains quote then
5127+
beep
5128+
answer error revIDELocalise("The name of the stack cannot contain quotes")
5129+
return false
5130+
end if
5131+
5132+
return true
5133+
end ideCheckStackName
5134+
51145135
on revIDEPropertySet pObjectList, pProperty, pValue, pLockUpdates
51155136
local tThrottlePropertyChanged
51165137
put false into tThrottlePropertyChanged
@@ -5132,27 +5153,14 @@ on revIDEPropertySet pObjectList, pProperty, pValue, pLockUpdates
51325153

51335154
# If stack name is changed, use new name when setting edited
51345155
if tStack is tObject and pProperty is "name" then
5135-
local tOldName
5136-
put the short name of tStack into tOldName
5137-
if char 1 to 3 of pValue is "rev" then
5138-
answer warning revIDELocalise("Using rev in the first three characters of a stack name is reserved for use by the LiveCode development environment and advanced users creating Plug-ins. If you use these characters, your stack may not behave as expected.") with revIDELocalise("OK") and revIDELocalise("Cancel")
5139-
if it is revIDELocalise("Cancel") then
5140-
set the name of tStack to tOldName
5141-
exit revIDEPropertySet
5142-
end if
5143-
end if
5144-
if pValue is a number then
5145-
beep
5146-
answer error revIDELocalise("You cannot set the name of a stack to a number.")
5147-
set the name of tStack to tOldName
5148-
exit revIDEPropertySet
5149-
end if
5150-
if pValue contains quote then
5151-
beep
5152-
answer error revIDELocalise("The name of the stack cannot contain quotes")
5156+
5157+
if not ideCheckStackName(pValue) then
5158+
local tOldName
5159+
put the short name of tStack into tOldName
51535160
set the name of tStack to tOldName
51545161
exit revIDEPropertySet
51555162
end if
5163+
51565164
put pValue into tStackName
51575165
else
51585166
put the short name of tStack into tStackName

Toolset/palettes/project browser/behaviors/revideprojectbrowsercontainerrowbehavior.livecodescript

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,12 @@ end mouseDoubleUp
334334

335335
on CloseFieldEditor pFieldEditor, pRow, pKey, pClosingTriggeredBy
336336
# The text the user entered is different than the current value of the target field.
337+
if word 1 of the cObjectLongID of me is "stack" and \
338+
not ideCheckStackName(the text of pFieldEditor) then
339+
// Force a refresh
340+
set the text of field "name" of me to the text of field "name" of me
341+
exit CloseFieldEditor
342+
end if
337343
set the textColor of field "name" of me to revIDEColor("text_3")
338344
set the text of field "name" of me to the text of pFieldEditor
339345
updateProperty the cObjectLongID of me, "name", the text of pFieldEditor

notes/bugfix-21809.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Ensure stack name cannot be set to a number via the Project Browser

0 commit comments

Comments
 (0)