Skip to content

org.springframework.web.servlet.tags.form.TagIdGenerator doesn't remove characters [] and double-quotes [SPR-5382] #10055

@spring-projects-issues

Description

@spring-projects-issues

Ilya opened SPR-5382 and commented

org.springframework.web.servlet.tags.form.TagIdGenerator which is used by tags checkboxes and radiobuttons doesn't filter out [] and double-quotes from id attribute. It breaks html and javascript for map-based properties. Can be fixed like this:

public static String nextId(String name, PageContext pageContext) {
	String attributeName = PAGE_CONTEXT_ATTRIBUTE_PREFIX + name;
	Integer currentCount = (Integer) pageContext.getAttribute(attributeName);
	currentCount = (currentCount != null ? new Integer(currentCount.intValue() + 1) : new Integer(1));
	pageContext.setAttribute(attributeName, currentCount);
	return (StringUtils.deleteAny(name, "[]\"") + currentCount.intValue());
}

Issue Links:

Backported to: 3.0.1

Metadata

Metadata

Assignees

Labels

status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions