From 18f273066e9d784b863d64dd797543b126a0d7a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tina=20M=C3=BCller?= Date: Thu, 24 Oct 2024 14:36:47 +0200 Subject: [PATCH] Fix pattern for needle tag Developer console showed me this error: Pattern attribute value ^[A-Za-z0-9-_]+$ is not a valid regular expression: Uncaught SyntaxError: Invalid regular expression: /^[A-Za-z0-9-_]+$/v: Invalid character class Apparently dashes have to be escaped. Moving it to the end of the character class (this would have fixed it for a perl regex) did not help. --- t/ui/12-needle-edit.t | 12 ++++++++++++ templates/webapi/step/edit.html.ep | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/t/ui/12-needle-edit.t b/t/ui/12-needle-edit.t index a878aa7192e..12eea7a9349 100644 --- a/t/ui/12-needle-edit.t +++ b/t/ui/12-needle-edit.t @@ -334,6 +334,18 @@ my $needlename = 'test-newneedle'; my $xoffset = my $yoffset = 200; subtest 'Create new needle' => sub { + subtest 'invalid needle tag is rejected' => sub { + $elem = $driver->find_element_by_id('newtag'); + $elem->send_keys('123'); + my $button = $driver->find_element_by_id('tag_add_button'); + ok !$button->is_enabled, 'tag too short, Add button not enabled'; + $elem->send_keys('4'); + ok $button->is_enabled, 'tag valid, Add button enabled'; + $elem->send_keys('!'); + ok !$button->is_enabled, 'tag invalid, Add button not enabled'; + $elem->clear; + }; + add_needle_tag(); # check needle name input diff --git a/templates/webapi/step/edit.html.ep b/templates/webapi/step/edit.html.ep index 516c57c960c..ad981ead409 100644 --- a/templates/webapi/step/edit.html.ep +++ b/templates/webapi/step/edit.html.ep @@ -191,7 +191,7 @@
+ pattern="^[A-Za-z0-9\-_]+$" minLength=4 title="[A-Za-z0-9-_], at least 4 characters">