Prevents line breaks in delivery service remapText field (UI and API)#4305
Conversation
…rites, regex remap and tr request/response headers
traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.DNS.tpl.html
Show resolved
Hide resolved
traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.HTTP.tpl.html
Show resolved
Hide resolved
traffic_portal/app/src/common/modules/form/deliveryService/form.deliveryService.anyMap.tpl.html
Show resolved
Hide resolved
d7cb9c0 to
1c9d89c
Compare
ocket8888
left a comment
There was a problem hiding this comment.
The regular expression you're using isn't multi-line; ^ and $ match the beginning and end of a line, respectively. So I can still do this:
>> temp0.name
<- "remapText"
>> temp0.tagName
<- "TEXTAREA"
>> temp0.attributes[4]
<- ng-pattern="/^[^\\n\\r]*$/"
>> temp0.value
<- "
this is a test
"
>> temp0.validity.patternMismatch
<- false
>> temp0.classList.contains("ng-invalid")
<- false
>> temp0.classList.contains("ng-valid")
<- true
well in the UI i am unable to enter anything on 2+ lines so that's what i was going for. for example ^^ is fine as it appears to get trimmed 2 lines with content isn't allowed. |
|
No, you still can. That'll get rejected by the API but the form shows no problems. According to the issue, the content of this field is:
so this value would still exhibit the problem. So it ought to not be considered correct - especially since submission will result in an error. |
hmm. i can't replicate. this submits fine in both chrome and firefox as i would hope. it makes it past the api so it appears to be getting trimmed. also, remap.config looks fine when i submit that value ^^ it's only when i added a value on a 2nd line that the field becomes invalid which is what i want. |
|
retest this please |
ocket8888
left a comment
There was a problem hiding this comment.
API/client integration tests pass (unrelated failure in TestStatsSummary notwithstanding), unit tests pass, you didn't add a TP UI test so I assume those all still pass (though honestly that'd be nice), manual requests show newlines rejected by API and for some reason I can't explain the ng-model bindings on textareas silently trim leading and trailing whitespace so that isn't really a problem either.
ocket8888
left a comment
There was a problem hiding this comment.
Actually, after running the tests again against this branch rebased on master and master itself, TestStatsSummary is failing only after this branch's changes. I have no idea how or why, but that seems to be the case.
ocket8888
left a comment
There was a problem hiding this comment.
Nevermind again, that was just a transient, inexplicable, temporary failure :))))))))))))))))))))
…apache#4305) * prevents line breaks in ds.remapText (UI and API) * adds test to ensure ds.remapText cannot include a line break * updated fixtures to include valid line breaks for edge/mid header rewrites, regex remap and tr request/response headers * adds period to GoDoc * no need for ng-pattern * textarea does not support pattern so switching back to ng-pattern (cherry picked from commit c025d22)
…#4305) (#4317) * prevents line breaks in ds.remapText (UI and API) * adds test to ensure ds.remapText cannot include a line break * updated fixtures to include valid line breaks for edge/mid header rewrites, regex remap and tr request/response headers * adds period to GoDoc * no need for ng-pattern * textarea does not support pattern so switching back to ng-pattern (cherry picked from commit c025d22)





What does this PR (Pull Request) do?
Rejects delivery service remapText with line breaks as it will result in a malformed remap.config file.
Which Traffic Control components are affected by this PR?
What is the best way to verify this PR?
Raw Remap Textdelivery service form field for a DNS, HTTP or ANY_MAP delivery service.If this is a bug fix, what versions of Traffic Control are affected?
The following criteria are ALL met by this PR