Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: Unescaped left brace in regex is deprecated... #124

Open
JesseHawkins-zz opened this issue Jun 22, 2016 · 2 comments
Open

Fixed: Unescaped left brace in regex is deprecated... #124

JesseHawkins-zz opened this issue Jun 22, 2016 · 2 comments

Comments

@JesseHawkins-zz
Copy link

I'm probably posting this in the wrong area, so please excuse my GitHub-noobyness.

When running plexWatch.pl, I was greeted with a few occurrences of, "Unescaped left brace in regex is deprecated..." along with line numbers. A quick Google indicates that curly braces need to be escaped to fix this error message, and that eventually this error message will become a syntax error. Seemed like a good enough justification to find a fix.

My modified script runs without issues, as far as I can tell, after I made these changes:

    $format =~ s/{{($regex)}}/$info->{$1}/g; ## regex replace variables
    $format =~ s/\[\]//g;                 ## trim any empty variable encapsulated in []
    $format =~ s/\s+/ /g;                 ## remove double spaces
    $format =~ s/\\n/\n/g;                ## allow \n to be an actual new line
    $format =~ s/{{newline}}/\n/g;        ## allow \n to be an actual new line

    ## special for now.. might make this more useful -- just thrown together since email can include a ton of info

    if ($format =~ /{{all_details}}/i) {
        $format =~ s/\s*{{all_details}}\s*//i;

Changed to:

    $format =~ s/\{\{($regex)\}\}/$info->{$1}/g; ## regex replace variables
    $format =~ s/\[\]//g;                 ## trim any empty variable encapsulated in []
    $format =~ s/\s+/ /g;                 ## remove double spaces
    $format =~ s/\\n/\n/g;                ## allow \n to be an actual new line
    $format =~ s/\{\{newline\}\}/\n/g;        ## allow \n to be an actual new line

    ## special for now.. might make this more useful -- just thrown together since email can include a ton of info

    if ($format =~ /\{\{all_details\}\}/i) {
        $format =~ s/\s*\{\{all_details\}\}\s*//i;

Hope that this is helpful to someone. :)

@rubicon
Copy link

rubicon commented Aug 19, 2016

Thanks for pointing this out. I escaped the { and } on lines 760, 764, 765 thanks to this direction. Only lines I needed to change to fix the errors I was getting, but wouldn't have figured it out without this post. Thanks a lot!

@C-Duv
Copy link

C-Duv commented Aug 7, 2017

Thanks for the info, I was also about to fix it like this and found the confirmation here.

Here is a patch for fast command-line patching:

--- plexWatch.pl        2017-08-07 01:51:45.641446183 +0200
+++ plexWatch.pl        2017-08-07 01:52:33.442447850 +0200
@@ -757,12 +757,12 @@
     $format =~ s/\[\]//g;                 ## trim any empty variable encapsulated in []
     $format =~ s/\s+/ /g;                 ## remove double spaces
     $format =~ s/\\n/\n/g;                ## allow \n to be an actual new line
-    $format =~ s/{{newline}}/\n/g;        ## allow \n to be an actual new line
+    $format =~ s/\{\{newline\}\}/\n/g;    ## allow \n to be an actual new line

     ## special for now.. might make this more useful -- just thrown together since email can include a ton of info

-    if ($format =~ /{{all_details}}/i) {
-        $format =~ s/\s*{{all_details}}\s*//i;
+    if ($format =~ /\{\{all_details\}\}/i) {
+        $format =~ s/\s*\{\{all_details\}\}\s*//i;
         $format .= sprintf("\n\n%10s %s\n","","-----All Details-----");
         my $f_extra;
         foreach my $key (keys %{$info} ) {

Apply patch with:

patch plexWatch.pl patch_file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants