Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • Strange bug with regexp validator in all browsers but Chrome

    Hi Isomorphic,

    please see this sample (v11.1p_2018-04-11) and change the validator in the XML file to
    Code:
    expression="^(?!\s).*(?<!\s)$"/>
    This expression should prevent space or tab-letters at beginning and ending of string.

    This is working fine in Chromium 65/Win10, but not in FF26/IE11/IE Edge on the same system or on Safari/MacOS.
    Here the Developer Console Output of IE Edge (the message is about the quantifier in all browsers):
    Code:
    15:04:45.183:INFO:Log:initialized
    15:04:45.596:INFO:Log:isc.Page is loaded
    15:04:57.253:MUP8:WARN:Log:SyntaxError: Unexpected quantifier
    Stack from error.stack:
    SyntaxError: Unexpected quantifier
       at isc.A.$74u.regexp.condition (https://www-demos.smartclient.com/smartclient-11.1/isomorphic/system/modules/ISC_Forms.js?isc_version=v11.1p_2018-04-11.js:1562:302)
       at isc_c_Validator_processValidator (https://www-demos.smartclient.com/smartclient-11.1/isomorphic/system/modules/ISC_Forms.js?isc_version=v11.1p_2018-04-11.js:1659:53)
       at isc_Canvas_validateField (https://www-demos.smartclient.com/smartclient-11.1/isomorphic/system/modules/ISC_Core.js?isc_version=v11.1p_2018-04-11.js:4188:1)
       at isc_DynamicForm_validate (https://www-demos.smartclient.com/smartclient-11.1/isomorphic/system/modules/ISC_Forms.js?isc_version=v11.1p_2018-04-11.js:511:1)
       at Function code (Function code:1:4)
       at isc_StatefulCanvas_handleActivate (https://www-demos.smartclient.com/smartclient-11.1/isomorphic/system/modules/ISC_Foundation.js?isc_version=v11.1p_2018-04-11.js:235:96)
       at isc_StatefulCanvas_handleClick (https://www-demos.smartclient.com/smartclient-11.1/isomorphic/system/modules/ISC_Foundation.js?isc_version=v11.1p_2018-04-11.js:236:1)
       at isc_c_EventHandler_bubbleEvent (https://www-demos.smartclient.com/smartclient-11.1/isomorphic/system/modules/ISC_Core.js?isc_version=v11.1p_2018-04-11.js:2055:78)
       at isc_c_EventHandler_handleClick (https://www-demos.smartclient.com/smartclient-11.1/isomorphic/system/modules/ISC_Core.js?isc_version=v11.1p_2018-04-11.js:1908:44)
       at isc_c_EventHandler__handleMouseUp (https://www-demos.smartclient.com/smartclient-11.1/isomorphic/system/modules/ISC_Core.js?isc_version=v11.1p_2018-04-11.js:1893:1)
    Do you somehow rewrite the Regexp?
    For me, it is happening the same way in an editable ListGrid. The validator definition comes from a type.xml-file:
    Code:
    <SimpleType xmlns:fmt="lmscompany/fmt" name="trimmedText" inheritsFrom="text">
        <fmt:bundle basename="com.lmscompany.lms.server.i18n.DSXMLResources-utf8" encoding="utf-8" />
        <validators>
            <validator type="regexp" expression="^(?!\s).*(?&lt;!\s)$">
                <errorMessage><fmt:message key="validatorWhitespaceNotAllowedAtBeginningOrEnd" /></errorMessage> 
            </validator>
        </validators>
    </SimpleType>
    I'll remove that code for now, but it would be great if you can have a look at this one.

    Best regards
    Blama

  • #2
    We're not transforming it, but your regexp is being parsed as XML then interpreted as a string, not a regexp literal. You need another backslash in front of the "s"s.

    Comment


    • #3
      Hi Isomorphic,

      sorry, this does not change the outcome in any browser, please try for yourself with this expression:
      Code:
      expression="^(?!\\s).*(?&lt;!\\s)$" />
      (same sample, now on v11.1p_2018-04-17)

      Best regards
      Blama

      Comment


      • #4
        It appears you are trying to use lookbehind in your regex which is only supported in Chrome 62+.

        Comment


        • #5
          Hi Isomorphic,

          OK, sorry, I did not know nor expect this. It's 2018, but OK, that's the way it is.

          For anyone interested, I found those links with the input of Isomorphic: [1], [2].

          Thank you & Best regards
          Blama

          Comment


          • #6
            More theory here.

            Comment


            • #7
              Pretty sure anyone can do it themselves, but this is the lookbehind-free (and therefore faster) equivalent version of the validator.
              Code:
              ^\S?$|^\S.*\S$
              Best regards
              Blama

              Comment


              • #8
                Hi @all,

                this made it as entry to caniuse.com just recently, so even if this (simple) case is now solved otherwise, you can track browser support here.

                Best regards
                Blama

                Comment

                Working...
                X