Glavin001 / atom-beautify

:mega: Help Wanted - Looking for Maintainer: https://github.com/Glavin001/atom-beautify/issues/2572 | :lipstick: Universal beautification package for Atom editor (:warning: Currently migrating to https://github.com/Unibeautify/ and have very limited bandwidth for Atom-Beautify Issues. Thank you for your patience and understanding :heart: )
http://unibeautify.com/
MIT License
1.5k stars 453 forks source link

Cannot read property '1' of null #2536

Closed uhlhosting closed 1 year ago

uhlhosting commented 3 years ago

Description

The results of beautification are not what I expect.

Input Before Beautification

This is what the code looked like before:

fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_path /mnt/ram/fastcgi-cache levels=1:2 keys_zone=WORDPRESS:256m max_size=1g inactive=60m use_temp_path=off;
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server
{
  listen 80 default_server;
  listen 443 ssl http2 default_server;
  server_name uhl.site www.uhl.site;
  index index.php;
  charset utf-8;
  root /www/wwwroot/uhl.site;

  #SSL-START SSL related configuration, do NOT delete or modify the next line of commented-out 404 rules
  #error_page 404/404.html;
  #HTTP_TO_HTTPS_START
  if ($server_port !~ 443)
  {
    rewrite ^(/.*)$ https://$host$1 permanent;
  }
  #HTTP_TO_HTTPS_END
  ssl_certificate /www/server/panel/vhost/cert/uhl.site/fullchain.pem;
  ssl_certificate_key /www/server/panel/vhost/cert/uhl.site/privkey.pem;
  ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
  ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
  ssl_prefer_server_ciphers on;
  ssl_session_cache shared:SSL:10m;
  ssl_session_timeout 10m;
  add_header Strict-Transport-Security "max-age=31536000";
  error_page 497 https://$host$request_uri;

  ssl_early_data on;
  ssl_dhparam /www/server/nginx/conf/ssl/ffdhe4096.pem; resolver 1.1.1.1 1.0.0.1;
  #SSL-END

  # START Security headers
  # security headers
  add_header X-Powered-By "UHL-Server";
  add_header X-Frame-Options SAMEORIGIN;
  add_header X-Content-Type-Options nosniff;
  add_header X-XSS-Protection "1; mode=block";
  add_header X-Permitted-Cross-Domain-Policies master-only;
  add_header Referrer-Policy "strict-origin";
  # This policy allows images, scripts, AJAX, and CSS from the same origin, and does not allow any other resources to load:
  add_header Content-Security-Policy "font-src data: 'self' cdn.bootcss.com fonts.gstatic.com; img-src data: 'self' ps.w.org s.w.org secure.gravatar.com 0.gravatar.com 1.gravatar.com 2.gravatar.com fancyfreelancer.oxy.host; script-src 'unsafe-eval' 'self' self crm.uhlhosting.ch cdn.ampproject.org cdn.jsdelivr.net storage.googleapis.com instant.page; style-src 'unsafe-eval' 'unsafe-inline' 'self' fonts.googleapis.com cdn.bootcss.com cdn.jsdelivr.net; media-src s.w.org; script-src-elem 'unsafe-inline' 'self' crm.uhlhosting.ch; style-src-attr 'unsafe-inline'; style-src-elem 'unsafe-inline' 'self';  report-uri https://uhlhosting.report-uri.com/r/d/csp/wizard
;" always;
  add_header Expect-CT 'max-age=60, report-uri="https://uhlhosting.report-uri.com/r/d/ct/reportOnly"' always;
  add_header Permissions-Policy "geolocation=();midi=();notifications=();push=();sync-xhr=();microphone=();camera=();magnetometer=();gyroscope=();speaker=(self);vibrate=();fullscreen=(self);payment=();";
  add_header Report-To "{\"group\":\"default\",\"max_age\":31536000,\"endpoints\":[{\"url\":\"https://uhlhosting.report-uri.com/a/d/g\"}],\"include_subdomains\":true}";
  #add_header Feature-Policy "geolocation 'none'; midi 'none'; notifications 'none'; push 'none'; sync-xhr 'none'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; speaker 'none'; vibrate 'none'; fullscreen 'none'; payment 'none'; usb 'none';";
  # END Security headers

  set $skip_cache 0;
  if ($request_method = POST)
  {
    set $skip_cache 1;
  }
  if ($http_cookie ~* "PHPSESSID")
  {
    set $skip_cache 1;
  }
  if ($query_string != "")
  {
    set $skip_cache 1;
  }
  if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml")
  {
    set $skip_cache 1;
  }
  if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in")
  {
    set $skip_cache 1;
  }
  location ~ [^/]\.php(/|$)
  {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    try_files $uri =404;
    fastcgi_pass unix:/tmp/php-cgi-74.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
    fastcgi_cache_bypass $skip_cache;
    fastcgi_no_cache $skip_cache;
    fastcgi_cache WORDPRESS;
    fastcgi_param HTTP_PROXY "";
    # Cache headers    etag on;
    fastcgi_cache_valid 200 301 302 1d;
  }

  location ~ /purge(/.*)
  {
    allow 127.0.0.1;
    allow 172.18.6.10;
    allow 137.74.247.206;
    deny all;
    fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
  }
  #ERROR-PAGE-START  Error page configuration, allowed to be commented, deleted or modified
  #error_page 404 /404.html;
  #error_page 502 /502.html;
  #ERROR-PAGE-END
  #SECURITY-START Hotlink protection configuration
  location ~ .*\.(jpg|jpeg|gif|png|js|css)$
  {
    expires 30d;
    access_log off;
    valid_referers none blocked uhl.site;
    if ($invalid_referer)
    {
      return 404;
    }
  }
  #SECURITY-END
  #PHP-INFO-START  PHP reference configuration, allowed to be commented, deleted or modified
  include enable-php-74.conf;
  #PHP-INFO-END

  #REWRITE-START URL rewrite rule reference, any modification will invalidate the rewrite rules set by the panel
  include /www/server/panel/vhost/rewrite/uhl.site.conf;
  #REWRITE-END

  # Forbidden files or directories
  location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
  {
    return 404;
  }

  # Directory verification related settings for one-click application for SSL certificate
  location ~ \.well-known
  {
    allow all;
  }

  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  {
    expires 30d;
    error_log off;
    access_log off;
  }

  location ~ .*\.(js|css)?$
  {
    expires 12h;
    error_log off;
    access_log off;
  }
  access_log /www/wwwlogs/uhl.site.log;
  error_log /www/wwwlogs/uhl.site.error.log;
}

Expected Output

The beautified code should have looked like this:

<INSERT CODE HERE>

Actual Output

The beautified code actually looked like this:

TypeError: Cannot read property '1' of null
    at Beautifier.extractTextBySeperator (/Users/cosmic/.atom/packages/atom-beautify/node_modules/nginxbeautify/nginxbeautify/main.js:57:47)
    at Beautifier.extractAllPossibleText (/Users/cosmic/.atom/packages/atom-beautify/node_modules/nginxbeautify/nginxbeautify/main.js:76:42)
    at Beautifier.strip_line (/Users/cosmic/.atom/packages/atom-beautify/node_modules/nginxbeautify/nginxbeautify/main.js:104:42)
    at Beautifier.clean_lines (/Users/cosmic/.atom/packages/atom-beautify/node_modules/nginxbeautify/nginxbeautify/main.js:125:62)
    at Beautifier.parse (/Users/cosmic/.atom/packages/atom-beautify/node_modules/nginxbeautify/nginxbeautify/main.js:34:35)
    at /Users/cosmic/.atom/packages/atom-beautify/src/beautifiers/nginx-beautify.coffee:32:26
    at Promise._execute (/Users/cosmic/.atom/packages/atom-beautify/node_modules/bluebird/js/release/debuggability.js:384:9)
    at Promise._resolveFromExecutor (/Users/cosmic/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:518:18)
    at new Promise (/Users/cosmic/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:103:10)
    at NginxBeautify.module.exports.NginxBeautify.beautify (/Users/cosmic/.atom/packages/atom-beautify/src/beautifiers/nginx-beautify.coffee:28:12)
    at /Users/cosmic/.atom/packages/atom-beautify/src/beautifiers/index.coffee:363:28
    at tryCatcher (/Users/cosmic/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/cosmic/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/cosmic/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromiseCtx (/Users/cosmic/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:641:10)
    at _drainQueueStep (/Users/cosmic/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:97:12)
    at _drainQueue (/Users/cosmic/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/cosmic/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:102:5)
    at Async.drainQueues (/Users/cosmic/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:15:14)

Steps to Reproduce

  1. Add code to Atom editor
  2. Run command Atom Beautify: Beautify Editor
  3. This beautified code does not look right!

Debug

Here is a link to the debug.md Gist: https://gist.github.com/uhlhosting/4d094363350c82589436c7d81b6557d8

Checklist

I have:

SilentGlasses commented 1 year ago

If you still need this and are looking for something to fill the spot that Atom left, I am using Pulsar the successor to Atom... This package is working except for one deprecated error listed in #2605

If you don't need this anymore, can you please close this out so it's not just sitting there? Thanks