Loading...
Loading...
Catalog client script is not validating data as expected when the code is executed on Service Portal. The code is using the javascript Regex test() function to validate a Base64 encoded security certificate. This is causing validation logic on users catalog item to not work as expected on the service portal. The same code executed in Desktop context is returning expected results for the same test value. The script is using Regex expression to validate the string is encoded in Base64 (as security certificate): var s = g_form.getValue('s'); alert("validate = " + ValidateBase_64(s)); function ValidateBase_64(x) { if (/^(\-+BEGIN[\d\D]+CERTIFICATE\sREQUEST\-+)(\n[\d\D]+\n)(\-+END[\d\D]+CERTIFICATE\sREQUEST\-+)[\n\s]*$/.test(x)) { return (true); } return (false); } Note: in the test catalog item 's' is a multi-line field.
Pre-requisite: import catalog item "RegexTest". Confirm expected behavior on desktop: 1. Go to /com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=0307dc211bf86d10ed932f02b24bcb07 2. Enter the following into the field: -----BEGIN CERTIFICATE REQUEST----- REDACTED -----END CERTIFICATE REQUEST----- 3. Click the Order Now button > see popup "validate = true" (this is expected behavior) Test on service portal: 1. Go to /sp?id=sc_cat_item&sys_id=0307dc211bf86d10ed932f02b24bcb07 2. Enter the following into the field: -----BEGIN CERTIFICATE REQUEST----- REDACTED -----END CERTIFICATE REQUEST----- 3. Click the Submit button > see popup "validate = false" (this is not expected and different than seen on desktop)
This behaviour change is caused by a fix for a previous problem, where new line characters (\n) are converted to CRLF (\r\n), so to bring consistency in the value being saved in the DB when submitted from platform vs portal. The workaround for the validation as in this case, is to alter the regex to include \r\n sequence, along with \n, like the following: /^(\-+BEGIN[\s\d\D]+CERTIFICATE\sREQUEST\-+)([\n|\r\n][\d\D]+[\n|\r\n])(\-+END[\d\D]+CERTIFICATE\sREQUEST\-+)[\n\r\s]*$/
PRB1640616
Click on a version to see all relevant bugs
ServiceNow Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.