(refs #21)Allow multi-byte chars in label name.

This commit is contained in:
takezoe
2013-07-06 04:19:35 +09:00
parent bcd88a1342
commit e6451c7ede

View File

@@ -13,12 +13,12 @@ trait LabelsControllerBase extends ControllerBase {
case class LabelForm(labelName: String, color: String) case class LabelForm(labelName: String, color: String)
val newForm = mapping( val newForm = mapping(
"newLabelName" -> trim(label("Label name", text(required, identifier, maxlength(100)))), "newLabelName" -> trim(label("Label name", text(required, labelName, maxlength(100)))),
"newColor" -> trim(label("Color", text(required, color))) "newColor" -> trim(label("Color", text(required, color)))
)(LabelForm.apply) )(LabelForm.apply)
val editForm = mapping( val editForm = mapping(
"editLabelName" -> trim(label("Label name", text(required, identifier, maxlength(100)))), "editLabelName" -> trim(label("Label name", text(required, labelName, maxlength(100)))),
"editColor" -> trim(label("Color", text(required, color))) "editColor" -> trim(label("Color", text(required, color)))
)(LabelForm.apply) )(LabelForm.apply)
@@ -47,4 +47,18 @@ trait LabelsControllerBase extends ControllerBase {
issues.labels.html.editlist(getLabels(repository.owner, repository.name), repository) issues.labels.html.editlist(getLabels(repository.owner, repository.name), repository)
}) })
/**
* Constraint for the identifier such as user name, repository name or page name.
*/
private def labelName: Constraint = new Constraint(){
def validate(name: String, value: String): Option[String] =
if(!value.matches("^[^,]+$")){
Some("%s contains invalid character.".format(name))
} else if(value.startsWith("_") || value.startsWith("-")){
Some("%s starts with invalid character.".format(name))
} else {
None
}
}
} }