Giter VIP home page Giter VIP logo

plack-middleware-rewrite's Issues

Invalid handling of arrayref results with redirects

If rules code returns arrayref with 3xx status, its location is ignored, usually resulting in infinite redirect.
Example:

use strict;
use warnings;

use Plack::Builder;

builder {
    enable 'Rewrite', rules => sub {
        return [ 302, [ Location => '/foo'], [] ] if /bar/;
    };
    sub {
        my $env = shift;
        return [200, [], [ "Path: $env->{PATH_INFO}" ] ];
    };
};

This app produces an infinite redirect if asked for /bar url.

PS: The reason I'm using it this way instead of substituting $_ and returning 302 is that I call external $app on different rules, and they handle some rewriting themselves.

test '... which is XSS-safe' failing

I got this error running tests:

#   Failed test '... which is XSS-safe'
#   at t/rewrite.t line 77.
#                   '<!DOCTYPE html><title>Moved</title>This resource has moved to <a href="http://localhost/tempted%26badly/">a new address</a>.'
#     doesn't match '(?^:<a href="http://localhost/tempted&amp;badly/">)'
# Looks like you failed 1 test of 29.
t/rewrite.t ..

The difference has to do with whether or not the & is URL-encoded. I don't know exactly what the test is doing, and whether this detail is important. But one fix would be this (line 124 of t/rewrite.t):

like $res->content, qr!<a href="http://localhost/tempted(&amp;|%26)badly/">!, '... which is XSS-safe';

Pass $res object to 'response' callback

This sounds very cool:

Its primary purpose is rewriting paths, but almost anything is possible very easily.

But:

Just as in request, the PSGI environment is passed as first and only argument.

From now I can not rewrite response code based on response body/headers

It will be cool if you pass whole $res array as second parameter too

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.