Announcement

Collapse
No announcement yet.

Phonenumber contains slash - Error: "Invalid"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Phonenumber contains slash - Error: "Invalid"

    [ EspoCRM v. 7.2.6]

    Hi all,

    when our EspoCRM had been set up, it allowed "/" in phonenumbers such as "+49 (0).../...". This worked well, so many phonennumbers have been filled in this way. Meanwhile, several Espo updates have been made, so current Version is 7.2.6. Now, when I lets say update a leads name - without touching the phonenumber - I get "Invalid" and "Only digits, latin letters and characters `-+_@:#().` are allowed'. I'm curious, in which version this has changed.
    Obviously, older records will contain slashes, which will cause errors. Seems I'll have to change all the old numbers to something like "+49 (0)...-..." directly in the database?

    Regards

  • #2
    Hi,

    You can change the regular expression: https://github.com/espocrm/espocrm/b...terns.json#L28.

    Create a file custom/Espo/Custom/Resources/metadata/app/regExpPatterns.json:

    Code:
    {
        "phoneNumberLoose": {
            "pattern": "[\\/0-9A-Za-z_@:#\\+\\(\\)\\-\\. ]+"
        }​
    }
    FIXED.
    Last edited by yuri; 11-07-2022, 01:59 PM.

    Comment


    • #3
      Hi Yuri,

      does not work, unfortunately. I get an Error 500, /data/logs/espo-2022-11-04.log has errors like

      [2022-11-04 15:07:42] ERROR: Uncaught Exception JsonException: "JSON syntax error in 'custom/Espo/Custom/Resources/metadata/app/regExpPatterns.json'." at /var/www/html/application/Espo/Core/Utils/File/Unifier.php line 250 {"exception":"[object] (JsonException(code: 0): JSON syntax error in 'custom/Espo/Custom/Resources/metadata/app/regExpPatterns.json'. at /var/www/html/application/Espo/Core/Utils/File/Unifier.php:250)"} []

      No change, if I delete the trailing comma in the "pattern" line. As I understand, the crucial part is "\\/" at the beginning of the regex. I get the error, even if I delete this part.
      Problems go away, if I delete the file regExpPatterns.json​.

      Comment


      • #4
        try this instead, seems you just need to remove the comma.

        Code:
        {
        "phoneNumberLoose": {
        "pattern": "[\\/0-9A-Za-z_@:#\\+\\(\\)\\-\\. ]+"
        }​
        }​
        Rabii
        Web Dev

        Comment


        • #5
          Hi rabii,
          that's what I thought also, buit it din't work in the first try. But I found a cryptic error in the json: I used http://json.parser.online.fr/, which showed additional characters behind the closing curly brackets. This caused an error. I could not recognize those characters neither in Microsoft's editor nor in n++. n++ only showed CR/LF or LF respectively, wich obviously did not cause the error.
          I fact, I fiddled around with json.parser.online and in a magical way got rid of those additional characters - don't ask me how or what it was! As a result, the error 500 did go away!
          Unfortunaltely, even after clearing the cache and rebuilding, I still cannot save records with phone numbers containing "/"-slashes.
          My json looks like this:
          Code:
          {
          "phoneNumberLoose": {
          "pattern": "[\\/0-9A-Za-z_@:#\\+\\(\\)\\-\\. ]+"
          }
          }
          • regExpPatterns.json is situated in /var/www/html/custom/Espo/Custom/Resources/metadata/app/
          • app/ and regExpPatterns.json both are owner:group www-data:www-data
          • app/ is set to 755
          • regExpPatterns.json is set to 644
          Any more ideas?

          Comment


          • #6
            Hi,
            if I copy your code, in a hex editor I can find:

            Click image for larger version  Name:	grafik.png Views:	0 Size:	26.8 KB ID:	84880​​
            zero-width space​!
            Regards
            Attached Files

            Comment


            • #7
              Got it!
              The regex doesn't need masking a "/"-slash. so it should read
              Code:
              [/0-9A-Za-z_@:#\\+\\(\\)\\-\\. ]
              Thanks for your help!

              Comment


              • rabii
                rabii commented
                Editing a comment
                glad you sorted it out

            • #8
              Sorry to reopen this issue ...
              It did work with version 7.2.6, does not work with version 7.2.7. Neither using
              Code:
              [/0-9A-Za-z_@:#\\+\\(\\)\\-\\. ]
              nor
              Code:
              [\\/0-9A-Za-z_@:#\\+\\(\\)\\-\\. ]

              Comment


              • #9
                I'll open a new thread ...

                Attached Files
                Last edited by agri; 12-02-2022, 10:36 AM.

                Comment

                Working...
                X