Commits

Anonymous committed f32d3cf

EXT-2403 Object name, description now forced to be ASCII characters only
Also fixes EXT-172, EXT-2399. Semantics now are:
Object name, object desc, parcel name, region name, inventory item name
all are ASCII only.
Parcel desc allows arbitrary Unicode chars.
Group names force ASCII only.
Reviewed with Leyla

Comments (0)

Files changed (20)

indra/llui/lllineeditor.cpp

 	declare("non_negative_s32", LLLineEditor::prevalidateNonNegativeS32);
 	declare("alpha_num", LLLineEditor::prevalidateAlphaNum);
 	declare("alpha_num_space", LLLineEditor::prevalidateAlphaNumSpace);
-	declare("printable_not_pipe", LLLineEditor::prevalidatePrintableNotPipe);
-	declare("printable_no_space", LLLineEditor::prevalidatePrintableNoSpace);
+	declare("ascii_printable_no_pipe", LLLineEditor::prevalidateASCIIPrintableNoPipe);
+	declare("ascii_printable_no_space", LLLineEditor::prevalidateASCIIPrintableNoSpace);
 }
 
 LLLineEditor::Params::Params()
 	return rv;
 }
 
+// Used for most names of things stored on the server, due to old file-formats
+// that used the pipe (|) for multiline text storage.  Examples include
+// inventory item names, parcel names, object names, etc.
 // static
-BOOL LLLineEditor::prevalidatePrintableNotPipe(const LLWString &str)
+BOOL LLLineEditor::prevalidateASCIIPrintableNoPipe(const LLWString &str)
 {
 	BOOL rv = TRUE;
 	S32 len = str.length();
 	if(len == 0) return rv;
 	while(len--)
 	{
-		if('|' == str[len])
+		llwchar wc = str[len];
+		if (wc < 0x20
+			|| wc > 0x7f
+			|| wc == '|')
 		{
 			rv = FALSE;
 			break;
 		}
-		if(!((' ' == str[len]) || LLStringOps::isAlnum((char)str[len]) || LLStringOps::isPunct((char)str[len])))
+		if(!(wc == ' '
+			 || LLStringOps::isAlnum((char)wc)
+			 || LLStringOps::isPunct((char)wc) ) )
 		{
 			rv = FALSE;
 			break;
 }
 
 
+// Used for avatar names
 // static
-BOOL LLLineEditor::prevalidatePrintableNoSpace(const LLWString &str)
+BOOL LLLineEditor::prevalidateASCIIPrintableNoSpace(const LLWString &str)
 {
 	BOOL rv = TRUE;
 	S32 len = str.length();
 	if(len == 0) return rv;
 	while(len--)
 	{
-		if(LLStringOps::isSpace(str[len]))
+		llwchar wc = str[len];
+		if (wc < 0x20
+			|| wc > 0x7f
+			|| LLStringOps::isSpace(wc))
 		{
 			rv = FALSE;
 			break;
 	return rv;
 }
 
+
 // static
 BOOL LLLineEditor::prevalidateASCII(const LLWString &str)
 {

indra/llui/lllineeditor.h

 	static BOOL		prevalidateNonNegativeS32(const LLWString &str);
 	static BOOL		prevalidateAlphaNum(const LLWString &str );
 	static BOOL		prevalidateAlphaNumSpace(const LLWString &str );
-	static BOOL		prevalidatePrintableNotPipe(const LLWString &str); 
-	static BOOL		prevalidatePrintableNoSpace(const LLWString &str);
+	static BOOL		prevalidateASCIIPrintableNoPipe(const LLWString &str); 
+	static BOOL		prevalidateASCIIPrintableNoSpace(const LLWString &str);
 	static BOOL		prevalidateASCII(const LLWString &str);
 
 	static BOOL		postvalidateFloat(const std::string &str);

indra/newview/llfloatergodtools.cpp

 BOOL LLPanelRegionTools::postBuild()
 {
 	getChild<LLLineEditor>("region name")->setKeystrokeCallback(onChangeSimName, this);
-	childSetPrevalidate("region name", &LLLineEditor::prevalidatePrintableNotPipe);
+	childSetPrevalidate("region name", &LLLineEditor::prevalidateASCIIPrintableNoPipe);
 	childSetPrevalidate("estate", &LLLineEditor::prevalidatePositiveS32);
 	childSetPrevalidate("parentestate", &LLLineEditor::prevalidatePositiveS32);
 	childDisable("parentestate");

indra/newview/llfloaterland.cpp

 {
 	mEditName = getChild<LLLineEditor>("Name");
 	mEditName->setCommitCallback(onCommitAny, this);	
-	childSetPrevalidate("Name", LLLineEditor::prevalidatePrintableNotPipe);
+	childSetPrevalidate("Name", LLLineEditor::prevalidateASCIIPrintableNoPipe);
 
 	mEditDesc = getChild<LLTextEditor>("Description");
 	mEditDesc->setCommitOnFocusLost(TRUE);
 	mEditDesc->setCommitCallback(onCommitAny, this);	
-	childSetPrevalidate("Description", LLLineEditor::prevalidatePrintableNotPipe);
-
+	// No prevalidate function - historically the prevalidate function was broken,
+	// allowing residents to put in characters like U+2661 WHITE HEART SUIT, so
+	// preserve that ability.
 	
 	mTextSalePending = getChild<LLTextBox>("SalePending");
 	mTextOwnerLabel = getChild<LLTextBox>("Owner:");

indra/newview/llfloaternamedesc.cpp

 	if (NameEditor)
 	{
 		NameEditor->setMaxTextLength(DB_INV_ITEM_NAME_STR_LEN);
-		NameEditor->setPrevalidate(&LLLineEditor::prevalidatePrintableNotPipe);
+		NameEditor->setPrevalidate(&LLLineEditor::prevalidateASCIIPrintableNoPipe);
 	}
 
 	y -= llfloor(PREVIEW_LINE_HEIGHT * 1.2f);
 	if (DescEditor)
 	{
 		DescEditor->setMaxTextLength(DB_INV_ITEM_DESC_STR_LEN);
-		DescEditor->setPrevalidate(&LLLineEditor::prevalidatePrintableNotPipe);
+		DescEditor->setPrevalidate(&LLLineEditor::prevalidateASCIIPrintableNoPipe);
 	}
 
 	y -= llfloor(PREVIEW_LINE_HEIGHT * 1.2f);

indra/newview/llfloaterproperties.cpp

 {
 	// build the UI
 	// item name & description
-	childSetPrevalidate("LabelItemName",&LLLineEditor::prevalidatePrintableNotPipe);
+	childSetPrevalidate("LabelItemName",&LLLineEditor::prevalidateASCIIPrintableNoPipe);
 	getChild<LLUICtrl>("LabelItemName")->setCommitCallback(boost::bind(&LLFloaterProperties::onCommitName,this));
-	childSetPrevalidate("LabelItemDesc",&LLLineEditor::prevalidatePrintableNotPipe);
+	childSetPrevalidate("LabelItemDesc",&LLLineEditor::prevalidateASCIIPrintableNoPipe);
 	getChild<LLUICtrl>("LabelItemDesc")->setCommitCallback(boost::bind(&LLFloaterProperties:: onCommitDescription, this));
 	// Creator information
 	getChild<LLUICtrl>("BtnCreator")->setCommitCallback(boost::bind(&LLFloaterProperties::onClickCreator,this));

indra/newview/llfolderview.cpp

 	params.font(getLabelFontForStyle(LLFontGL::NORMAL));
 	params.max_length_bytes(DB_INV_ITEM_NAME_STR_LEN);
 	params.commit_callback.function(boost::bind(&LLFolderView::commitRename, this, _2));
-	params.prevalidate_callback(&LLLineEditor::prevalidatePrintableNotPipe);
+	params.prevalidate_callback(&LLLineEditor::prevalidateASCIIPrintableNoPipe);
 	params.commit_on_focus_lost(true);
 	params.visible(false);
 	mRenamer = LLUICtrlFactory::create<LLLineEditor> (params);

indra/newview/llpanelgroupgeneral.cpp

 	}
 	mFounderName = panel_group->getChild<LLNameBox>("founder_name");
 	mGroupNameEditor = panel_group->getChild<LLLineEditor>("group_name_editor");
+	mGroupNameEditor->setPrevalidate( LLLineEditor::prevalidateASCII );
 }
 
 // static

indra/newview/llpanellogin.cpp

 	}
 
 #if !USE_VIEWER_AUTH
-	childSetPrevalidate("first_name_edit", LLLineEditor::prevalidatePrintableNoSpace);
-	childSetPrevalidate("last_name_edit", LLLineEditor::prevalidatePrintableNoSpace);
+	childSetPrevalidate("first_name_edit", LLLineEditor::prevalidateASCIIPrintableNoSpace);
+	childSetPrevalidate("last_name_edit", LLLineEditor::prevalidateASCIIPrintableNoSpace);
 
 	childSetCommitCallback("password_edit", mungePassword, this);
 	getChild<LLLineEditor>("password_edit")->setKeystrokeCallback(onPassKey, this);

indra/newview/llpanelpermissions.cpp

 BOOL LLPanelPermissions::postBuild()
 {
 	childSetCommitCallback("Object Name",LLPanelPermissions::onCommitName,this);
-	childSetPrevalidate("Object Name",LLLineEditor::prevalidatePrintableNotPipe);
+	childSetPrevalidate("Object Name",LLLineEditor::prevalidateASCIIPrintableNoPipe);
 	childSetCommitCallback("Object Description",LLPanelPermissions::onCommitDesc,this);
-	childSetPrevalidate("Object Description",LLLineEditor::prevalidatePrintableNotPipe);
+	childSetPrevalidate("Object Description",LLLineEditor::prevalidateASCIIPrintableNoPipe);
 
 	
 	getChild<LLUICtrl>("button set group")->setCommitCallback(boost::bind(&LLPanelPermissions::onClickGroup,this));

indra/newview/llpreviewanim.cpp

 	childSetAction("Anim audition btn",auditionAnim, this);
 
 	childSetCommitCallback("desc", LLPreview::onText, this);
-	childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);
+	childSetPrevalidate("desc", &LLLineEditor::prevalidateASCIIPrintableNoPipe);
 	
 	return LLPreview::postBuild();
 }

indra/newview/llpreviewgesture.cpp

 	{
 		childSetCommitCallback("desc", LLPreview::onText, this);
 		childSetText("desc", item->getDescription());
-		childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);
+		childSetPrevalidate("desc", &LLLineEditor::prevalidateASCIIPrintableNoPipe);
 	}
 
 	return LLPreview::postBuild();

indra/newview/llpreviewnotecard.cpp

 	childSetCommitCallback("desc", LLPreview::onText, this);
 	if (item)
 		childSetText("desc", item->getDescription());
-	childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);
+	childSetPrevalidate("desc", &LLLineEditor::prevalidateASCIIPrintableNoPipe);
 
 	return LLPreview::postBuild();
 }

indra/newview/llpreviewscript.cpp

 
 	childSetCommitCallback("desc", LLPreview::onText, this);
 	childSetText("desc", item->getDescription());
-	childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);
+	childSetPrevalidate("desc", &LLLineEditor::prevalidateASCIIPrintableNoPipe);
 
 	return LLPreview::postBuild();
 }

indra/newview/llpreviewsound.cpp

 	button->setSoundFlags(LLView::SILENT);
 
 	childSetCommitCallback("desc", LLPreview::onText, this);
-	childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);	
+	childSetPrevalidate("desc", &LLLineEditor::prevalidateASCIIPrintableNoPipe);	
 
 	return LLPreview::postBuild();
 }

indra/newview/llpreviewtexture.cpp

 		{
 			childSetCommitCallback("desc", LLPreview::onText, this);
 			childSetText("desc", item->getDescription());
-			childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);
+			childSetPrevalidate("desc", &LLLineEditor::prevalidateASCIIPrintableNoPipe);
 		}
 	}
 	

indra/newview/llsidepaneliteminfo.cpp

 
 	// build the UI
 	// item name & description
-	childSetPrevalidate("LabelItemName",&LLLineEditor::prevalidatePrintableNotPipe);
+	childSetPrevalidate("LabelItemName",&LLLineEditor::prevalidateASCIIPrintableNoPipe);
 	//getChild<LLUICtrl>("LabelItemName")->setCommitCallback(boost::bind(&LLSidepanelItemInfo::onCommitName,this));
-	childSetPrevalidate("LabelItemDesc",&LLLineEditor::prevalidatePrintableNotPipe);
+	childSetPrevalidate("LabelItemDesc",&LLLineEditor::prevalidateASCIIPrintableNoPipe);
 	//getChild<LLUICtrl>("LabelItemDesc")->setCommitCallback(boost::bind(&LLSidepanelItemInfo:: onCommitDescription, this));
 
 	// Creator information

indra/newview/llsidepaneltaskinfo.cpp

 	mBuyBtn = getChild<LLButton>("buy_btn");
 	mBuyBtn->setClickedCallback(boost::bind(&LLSidepanelTaskInfo::onBuyButtonClicked, this));
 
-	childSetPrevalidate("Object Name",LLLineEditor::prevalidatePrintableNotPipe);
-	childSetPrevalidate("Object Description",LLLineEditor::prevalidatePrintableNotPipe);
+	childSetPrevalidate("Object Name",LLLineEditor::prevalidateASCIIPrintableNoPipe);
+	childSetPrevalidate("Object Description",LLLineEditor::prevalidateASCIIPrintableNoPipe);
 
 //	getChild<LLUICtrl>("button set group")->setCommitCallback(boost::bind(&LLSidepanelTaskInfo::onClickGroup,this));
 //	childSetAction("button deed",LLSidepanelTaskInfo::onClickDeedToGroup,this);

indra/newview/skins/default/xui/en/floater_test_line_editor.xml

     Enabled line editor
   </line_editor>
   <line_editor
-    enabled="false"
+   height="20"
+   layout="topleft"
+   left_delta="0"
+   name="ascii_line_editor"
+   prevalidate_callback="ascii"
+   tool_tip="ascii line editor"
+   top_pad="10" 
+   width="200">
+    ASCII only line editor
+  </line_editor>
+  <line_editor
+   enabled="false"
    height="20"
    layout="topleft"
    left_delta="0"

indra/newview/skins/default/xui/en/floater_tools.xml

                 Mixed Sale
             </panel.string>
             <text
-             type="string"
-             length="1"
              follows="left|top"
              height="10"
-             layout="topleft"
              left="10"
              name="Name:"
              top="0"
             <line_editor
              follows="left|top|right"
              height="19"
-             layout="topleft"
              left_pad="0"
              max_length="63"
              name="Object Name"
              top_delta="0"
              width="170" />
             <text
-             type="string"
-             length="1"
              follows="left|top"
              height="10"
-             layout="topleft"
              left="10"
              name="Description:"
              top_pad="3"
             <line_editor
              follows="left|top|right"
              height="19"
-             layout="topleft"
              left_pad="0"
              max_length="127"
              name="Object Description"