cnken / substitutions4nginx

Automatically exported from code.google.com/p/substitutions4nginx
3 stars 3 forks source link

Broken substitution #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Here is config line:

subs_filter 'http://gymboree.hs.llnwd.net/e2/media/GYM/images/' 
'http://gymboree-russia.com/e2/media/GYM/images/' g;

Origin body part:

<!-- END: Header and Nav Table --> 
          <div id=main_images 
            style="BORDER-RIGHT: black 0px solid; PADDING-RIGHT: 0px; BORDER-TOP: black 0px solid; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; BORDER-LEFT: black 0px solid; WIDTH: 865px; PADDING-TOP: 0px; BORDER-BOTTOM: black 0px solid; POSITION: relative; HEIGHT: 710px; BACKGROUND-COLOR: #ffffff"> 
          <div id=photo1 
            style="Z-INDEX: 1; LEFT: 433px; VISIBILITY: visible; WIDTH: 216px; POSITION: absolute; TOP: 550px; HEIGHT: 150px"><img border="0" src="http://gymboree.hs.llnwd.net/e2/media/GYM/images/2004redesign/A_promotions/2005Addt20off/ACTIVE_Sale_PressKit_732_v1_m56577569830752654.gif" width="216" height="150" usemap="#db_img_map_4" alt="Gymboree" /><map NAME="db_img_map_4"><area SHAPE="rect" ALT="Gymboree" COORDS="1,47,68,65" HREF="http://www.gymboree.com/shop/dept_category.jsp?FOLDER%3C%3Efolder_id=2534374305284913&ASSORTMENT%3C%3East_id=1408474395917465&bmUID=1298444996141&WT.ac=ACTIVE_Sale_PressKit_732_SaleNG"><area SHAPE="rect" ALT="ACTIVE_Sale_PressKit_732.gif" COORDS="71,47,153,65" HREF="http://www.gymboree.com/shop/dept_category.jsp?FOLDER%3C%3Efolder_id=2534374305284885&ASSORTMENT%3C%3East_id=1408474395917465&bmUID=1298444996142&WT.ac=ACTIVE_Sale_PressKit_732_SaleNB"><area SHAPE="rect" ALT="ACTIVE_Sale_PressKit_732.gif" COORDS="157,47,213,66" HREF="http://www.gymboree.com/shop/dept_category.jsp?FOLDER%3C%3Efolder_id=2534374304777285&ASSORTMENT%3C%3East_id=1408474395917465&bmUID=1298444996142&WT.ac=ACTIVE_Sale_PressKit_732_SaleBG"><area SHAPE="rect" ALT="ACTIVE_Sale_PressKit_732.gif" COORDS="2,73,188,146" HREF="http://s7d1.scene7.com/s7/brochure/flash_brochure.jsp?company=Gymboree&sku=eCatalog%5FSpring2011&config=Gymboree/Facebook_GYM&locale=en&WT.ac=ACTIVE_Sale_PressKit_732_ecatalog_Holiday"><area SHAPE="rect" ALT="ACTIVE_Sale_PressKit_732.gif" COORDS="190,75,214,146" HREF="http://www.gymboree.com/our_company/help_template.jsp?FOLDER%3C%3Efolder_id=2534374306254365&ASSORTMENT%3C%3East_id=1408474395917465&bmUID=1298444996142&WT.ac=ACTIVE_Sale_PressKit_732_GymBucksRedemptionInfo"></map> 
            </div>

Result of substitution:

<!-- END: Header and Nav Table --> 
          <div id=main_images 
            style="BORDER-RIGHT: black 0px solid; PADDING-RIGHT: 0px; BORDER-TOP: black 0px solid; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; BORDER-LEFT: black 0px solid; WIDTH: 865px; PADDING-TOP: 0px; BORDER-BOTTOM: black 0px solid; POSITION: relative; HEIGHT: 710px; BACKGROUND-COLOR: #ffffff"> 
          <div id=photo1 
            style="Z-INDEX: 1; LEFT: 433px; VISIBILITY: visible; WIDTH: 216px; POSITION: absolute; TOP: 550px; HEIGHT: 150px"><img border="0" src="http://gymboree-russia.com/e2/media/GYM/images/2004redesign/A_promotions/2005Addt20off/ACTIVE_Sale_PressKit_732_v1_m56577569830752654.gif" width="216" height="150" usemap="#db_img_map_4" alt="Gymboree" /><map NAME="db_img_map_4"><area SHAPE="rect" ALT="Gymboree" COORDS="1,47,68,65" HREF="http://gymboree-russia.com/shop/dept_category.jsp?FOLDER%3C%3Efolder_id=2534374305284913&ASSORTMENT%3C%3East_id=1408474395917465&bmUID=1298444870069&WT.ac=ACTIVE_Sale_PressKit_732_SaleNG"><area SHAPE="rect" ALT="ACTIVE_Sale_PressKit_732.gif" COORDS="71,47,153,65" HREF="http://gymboree-russia.com/shop/dept_category.jsp?FOLDER%3C%3Efolder_id=2534374305284885&ASSORTMENT%3C%3East_id=1408474395917465&bmUID=1298444870069&WT.ac=ACTIVE_Sale_PressKit_732_SaleNB"><area SHAPE="rect" ALT="ACTIVE_Sale_PressKit_732.gif" COORDS="157,47,213,66" HREF="http://gymboree-russia.com/shop/dept_category.jsp?FOLDER%3C%3Efolder_id=2534374304777285&ASSORTMENT%3C%3East_id=1408474395917465&bmUID=1298444870069&WT.ac=ACTIVE_Sale_PressKit_732_SaleBG"><area SHAPE="rect" ALT="ACTIVE_Sale_PressKit_732.gif" COORDS="2,73,188,146" HREF="http://s7d1.scene7.com/s7/brochure/flash_brochure.jsp?company=Gymboree&sku=eCatalog%5FSpring2011&config=Gymboree/Facebook_GYM&locale=en&WT.ac=ACTIVE_Sale_PressKit_732_ecatalog_Holiday"><area SHAPE="rect" ALT="ACTIVE_Sale_PressKit_732.gif" COORDS="190,75,214,146" HREF="http://gymboree-ru            style="Z-INDEX: 1; LEFT: 433px; VISIBILITY: visible; WIDTH: 216px; POSITION: absolute; TOP: 550px; HEIGHT: 150px"><img border="0" src="http://gymboree-russia.com/e2/media/GYM/images/2004re          </div>

Last link is broken: "http://gymboree-ru  " and is replaced by the begining of 
first line (whitch contains first match):  "style="Z-INDEX: 1; LEFT: 433px; ..."

Centos 5.5
Linux Srv1 2.6.18-194.26.1.el5xen #1 SMP Tue Nov 9 13:35:30 EST 2010 x86_64 
x86_64 x86_64 GNU/Linux

nginx-0.8.54

Original issue reported on code.google.com by r.shishkin@gmail.com on 23 Feb 2011 at 7:31

GoogleCodeExporter commented 9 years ago
Hi, Can you show me your debug log and config file? To activate debugging log 
you have to compile nginx with --with-debug configure option and set debug 
level in error_log directive. 

Thanks.

Original comment by yaoweibin@gmail.com on 23 Feb 2011 at 8:46

GoogleCodeExporter commented 9 years ago
Here is config

file ngnix.conf:
----------------

user  nginx nginx;
worker_processes  4;

#error_log  logs/error.log info;
error_log  logs/error.log debug;

pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    resolver   127.0.0.1;

    include    options.conf;
    include    mime.types;
    charset    utf-8;
    override_charset on;
    source_charset    iso-8859-1;

    charset_map  iso-8859-1 utf-8 { }

    proxy_buffers 8 64k;
    proxy_connect_timeout 5s;
    proxy_read_timeout 5s;
    proxy_send_timeout 5s;
    proxy_next_upstream off;
    proxy_intercept_errors  off;

    proxy_cache_path      /usr/local/nginx/proxy_temp/ levels=1:2 keys_zone=cache-zone:10m inactive=10m max_size=1000M;
    proxy_store_access    user:rw  group:rw  all:r;

    include    gymboree.conf;

    access_log  logs/access.log  main;
}

file options.conf:
-----------------

## Size Limits
  client_body_buffer_size     128K;
  client_header_buffer_size   1M;
  client_max_body_size          1M;
  large_client_header_buffers 8 8k;

 ## Timeouts
  client_body_timeout   60;
  client_header_timeout 60;
  expires               24h;
  keepalive_timeout     60 60;
  send_timeout          60;

 ## General Options
  ignore_invalid_headers   on;
  keepalive_requests      100;
  limit_zone gulag $binary_remote_addr 5m;
  recursive_error_pages    on;
  sendfile                 on;
  server_name_in_redirect off;
  server_tokens           off;

 ## TCP options
  tcp_nodelay on;
  tcp_nopush  on;

 ## Compression
  gzip              on;
  gzip_buffers      16 8k;
  gzip_comp_level   1;
  gzip_http_version 1.0;
  gzip_min_length   1024;
  gzip_types        text/plain text/css image/x-icon application/x-perl application/x-httpd-cgi;
  gzip_vary         on;

 ## Log Format
  log_format  main  '$remote_addr $host $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" "$http_user_agent" '
                    '"$gzip_ratio"';

file gymboree.conf:
-------------------

server {
    listen          80;
    server_name     gymboree-russia.com;

    access_log  logs/gymboree-russia.access.log main;
    error_log   logs/gymboree-russia.error.log debug;
    index       index.html;
    root        /usr/local/nginx/html/gymboree-russia;

    ## redirect www to nowww
    if ($host = 'www.gymboree-russia.com' ) {
         rewrite  ^/(.*)$  http://gymboree-russia.com/$1  permanent;
    }

    # Redirect buggy pages 
    # Product Viwer
        rewrite ^/(shop/prod_close_up.*) http://www.gymboree.com/$1 permanent;

    ## Only allow these request methods
    if ($request_method !~ ^(GET|HEAD|POST)$ ) {
         return 444;
    }

#    location ^~ /gymboree.hs.llnwd.net/ {
    location ^~ /e2/ {

        root         /usr/local/nginx/html/gymboree-russia.com;

        access_log   logs/1.access.log;
        error_log   logs/1.error.log debug;

#       try_files $uri $uri/ @static;
        error_page 400 401 402 403 404 405 406 = @static;

    }

    location @static {
        proxy_pass http://gymboree.hs.llnwd.net$uri;
        proxy_store /usr/local/nginx/html/gymboree-russia.com${uri};
        expires max;

        access_log   logs/2.access.log;
        error_log   logs/2.error.log debug;
    }

    location / {
#        include    gymboree-transform.conf;
# Just buggy subs
        include    gymboree-test.conf;

        proxy_pass            http://gymboree.com;
        proxy_redirect        off;
        proxy_cache           cache-zone;
        proxy_cache_min_uses  2;
        proxy_cache_valid  200 1h;

        proxy_set_header      Host            $host;
        proxy_set_header      X-Real-IP       $remote_addr;
        proxy_set_header      X-Forwarded-For $proxy_add_x_forwarded_for;

    }

#    # redirect server error pages to the static page /50x.html
#    error_page   500 502 503 504  /50x.html;
#   location = /50x.html {
#           root   html;
#    }
}

file gymboree-test.conf:
-----------------------

#sub_filter 'http://gymboree.hs.llnwd.net/e2/media/GYM/images/' 
'http://gymboree-russia.com/e2/media/GYM/images/' ;
#sub_filter_once off;

subs_filter_types text/html;

subs_filter '<title[^>]*>(.*?)</title>' '<title>Gymboree в Росии - 
Детская одежда</title>' oir;

# Bug in multiply translation!
subs_filter 'http://gymboree.hs.llnwd.net/e2/media/GYM/images/' 
'http://gymboree-russia.com/e2/media/GYM/images/' gr;

Original comment by r.shishkin@gmail.com on 23 Feb 2011 at 9:54

Attachments:

GoogleCodeExporter commented 9 years ago
done, Try the latest revision. This bug should be fixed.

Thanks for your detail report.

Original comment by yaoweibin@gmail.com on 24 Feb 2011 at 4:17

GoogleCodeExporter commented 9 years ago
It works good. Probably need some more tests to be sure.
Thank you!

Original comment by r.shishkin@gmail.com on 24 Feb 2011 at 6:30