Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added validation for HTML tag names in the `tag` and `content_tag` helper method. The `tag` and `content_tag` method now checks that the provided tag name adheres to the HTML specification. If an invalid HTML tag name is provided, the method raises an `ArgumentError` with an appropriate error message. Examples: ```ruby content_tag("12p") # Starting with a number content_tag("") # Empty tag name tag("div/") # Contains a solidus tag("image file") # Contains a space ```
- Loading branch information
1 parent
fb6c600
commit bb626ff
Showing
3 changed files
with
59 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,23 @@ | ||
* Added validation for HTML tag names in the `tag` and `content_tag` helper method. The `tag` and | ||
`content_tag` method now checks that the provided tag name adheres to the HTML specification. If | ||
an invalid HTML tag name is provided, the method raises an `ArgumentError` with an appropriate error | ||
message. | ||
|
||
Examples: | ||
|
||
```ruby | ||
# Raises ArgumentError: Invalid HTML5 tag name: 12p | ||
content_tag("12p") # Starting with a number | ||
|
||
# Raises ArgumentError: Invalid HTML5 tag name: "" | ||
content_tag("") # Empty tag name | ||
|
||
# Raises ArgumentError: Invalid HTML5 tag name: div/ | ||
tag("div/") # Contains a solidus | ||
|
||
# Raises ArgumentError: Invalid HTML5 tag name: "image file" | ||
tag("image file") # Contains a space | ||
``` | ||
|
||
*Akhil G Krishnan* | ||
Please check [7-1-stable](https://github.com/rails/rails/blob/7-1-stable/actionview/CHANGELOG.md) for previous changes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters