Giter VIP home page Giter VIP logo

rewrite's People

Contributors

andreiamariei avatar andrewcromwell avatar balta3 avatar beikov avatar bryncooke avatar ceefour avatar cgendreau avatar chkal avatar codylerum avatar dboldureanu avatar dependabot[bot] avatar fabmars avatar gastaldi avatar gitter-badger avatar janario avatar jlleitschuh avatar jsight avatar kalgon avatar larsgrefer avatar lincolnthree avatar mbenson avatar mdfst13 avatar romixch avatar rumdidumdum avatar seanf avatar silvafabio avatar tires avatar tobias-ullerich-init avatar wienczny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rewrite's Issues

Switch to asciidoctor-java-integration library

Alex Soto (@lordofthejars) has been working on an Asciidoctor Java integration library that will handle all the dirty work of getting the required gems and the bridge code to invoke Ruby. I encourage the project to adopt this library to keep things simple & maintainable.

https://github.com/lordofthejars/asciidoctor-java-integration

Note that this will be moved upstream to this location any time now:

https://github.com/asciidoctor/asciidoctor-java-integration

FacesFileNotFoundException - Resource Not Found in ExternalContext as a Resource

Hi,

rewrite looks awesome :) There is a tiny little thing I would love to see:
I am using the faces-integration and I defined a
.addRule(Join.path("/{locale}/{page}.xhtml").to("/{page}.xhtml")

if I now define the de/index.xhtml accordingly to that I get a
com.sun.faces.context.FacesFileNotFoundException: /de/index.xhtml Not Found in ExternalContext as a Resource

Would be awesome to be able to define rewritten URLs as welcome-files ...

Using latest GF 3.1.2.2 with Mojarra 2.1.6 (SNAPSHOT 20111206).

Thanks,

  • M

Rewrite doesn't support rules where the target contains #

I created the following rule:

return ConfigurationBuilder.begin().defineRule().when(Direction.isInbound().and(Path.matches("/qr/{qrId}")))
.perform(Forward.to("/qms/index.html#view-qr{qrId}"));

When I attempt to use it, I get a 404 not found. I am able to copy and paste the exact URL in to my browser and it works.

Asciidoc renderer omits H1 tags

Tags rendered with = title = are omitted because by default, asciidoc treats these elements as the document title, and does not render them on single page requests.

Need to pass the !notitle flag when calling render(input)

Or jason porter suggested passing header-footer:

Asciidoctor.render('Asciidoc text goes here', :header_footer => true)

WELD-001318 / WELD-001409 Ambiguous dependency

Since commit 9e8bbb5 ("Expressions support no longer requires solder directly") a JSF app using both Rewrite and Solder (or anything that depends on it like Seam-Faces) will fail to deploy because Weld will see 2 ELContext producers.

org.ocpsoft.rewrite.cdi.expressions.ELContextProducer contains indeed:
@produces ELContext createELContext() {
return createELContext(resolver, functionMapper.get(), variableMapper.get());
}
Just like Solder. Hence the ambiguous dependency.

Rewrite Transform ResourceResolver API should accept EvaluationContext parameters

           .defineRule()
           .when(Path.matches("{something}.css").where("something").matches(".*"))
           .perform(Transform.with(Less.class)
                    .resolvedBy(WebResourceResolver.fileType(".less")));

Should probably look more like:

           .defineRule()
           .when(Path.matches("{something}.css").where("something").matches(".*"))
           .perform(Transform.with(Less.class)
                    .resolvedBy(WebResourceResolver.named("{something}.less")));

Exception encountered when parsing empty query-string

http://localhost:8080/socialpm-gwt/login?

java.lang.StringIndexOutOfBoundsException: String index out of range: -1 java.lang.String.substring(String.java:1937) java.lang.String.substring(String.java:1904) org.ocpsoft.rewrite.servlet.impl.HttpInboundRewriteImpl.getRequestQueryString(HttpInboundRewriteImpl.java:194) org.ocpsoft.rewrite.servlet.impl.HttpInboundRewriteImpl.getRequestQueryStringSeparator(HttpInboundRewriteImpl.java:182) org.ocpsoft.rewrite.servlet.impl.HttpInboundRewriteImpl.getURL(HttpInboundRewriteImpl.java:200) org.ocpsoft.rewrite.servlet.config.QueryString$2.evaluateHttp(QueryString.java:123) org.ocpsoft.rewrite.servlet.config.HttpCondition.evaluate(HttpCondition.java:41) org.ocpsoft.rewrite.config.And.evaluate(And.java:55) org.ocpsoft.rewrite.config.RuleBuilder.evaluate(RuleBuilder.java:93) org.ocpsoft.rewrite.servlet.impl.DefaultHttpRewriteProvider.rewriteHttp(DefaultHttpRewriteProvider.java:62) org.ocpsoft.rewrite.servlet.http.HttpRewriteProvider.rewrite(HttpRewriteProvider.java:44) org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:221) org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:177) org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65) org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)

Schemaless URLs don't work with CDN rule

When I use this rule with an application deployed to the context path /myapp:

.addRule(
    CDN.relocate("/faces/javax.faces.resource/jquery.js")
        .to("//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js")
)

I'm getting:

<script type="text/javascript" src="/myapp//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

It's the recommended way to use schemaless URLs to let the browser choose whether to use SSL or not when requesting the URL.

See:

https://developers.google.com/speed/libraries/devguide#jquery

Does it work with JBoss 4.X ?

Does it work with JBoss 4.X ? i have added in META-INF/services/.... but i can't able to see any log which says its installed. Do we need to specify anything in web.xml?

withInboundCorrection don't work with query parameters

Hello,
i add this rule:
.addRule(Join.path("/u/{name}").to("/protected/index.jsp?u={name}").withInboundCorrection())
but when i entered url('protected/index.jsp?u=someone'),i hadn't see expected url('u/someone'),it seems that withInboundCorrection don't work with parameter?
~Richard

Less transformer fails to render Bootstrap styles


org.mozilla.javascript.JavaScriptException: [object Object] (Less#14014)
    org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1057)
    org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)
    org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
    org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)
    org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3178)
    org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175)
    org.mozilla.javascript.Context.evaluateString(Context.java:1111)
    org.ocpsoft.rewrite.transform.less.Less.transform(Less.java:61)
    org.ocpsoft.rewrite.transform.StringTransformer.transform(StringTransformer.java:43)
    org.ocpsoft.rewrite.transform.PipelineOutputBuffer.transform(PipelineOutputBuffer.java:62)
    org.ocpsoft.rewrite.transform.PipelineOutputBuffer.execute(PipelineOutputBuffer.java:44)
    org.ocpsoft.rewrite.servlet.impl.HttpRewriteWrappedResponse.flushBufferedStreams(HttpRewriteWrappedResponse.java:114)
    org.ocpsoft.rewrite.servlet.impl.DefaultRewriteLifecycleListener.afterInboundLifecycle(DefaultRewriteLifecycleListener.java:36)
    org.ocpsoft.rewrite.servlet.impl.DefaultRewriteLifecycleListener.afterInboundLifecycle(DefaultRewriteLifecycleListener.java:9)
    org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:189)
    org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)
    org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)

It seems to be related to imports.

Wrong query parameters are injected when using annotations

I just ran into this issue with 2.0.0.Final.

@Join(path="/something", to="/faces/view.xhtml")
public class SomeBean {
  @Parameter
  private String value;
} 

Everything is fine with this URL:

/something?value=foobar

The value field contains foobar. But when I add another query parameter like this to the URL like this:

/something?value=foobar&abc=123

In this case the value field contains the value 123 instead of foobar.

Random NPE when rendering SASS files

Since updating to 2.0.0.Beta2 we are getting random exceptions when rendering SASS files. It happens only sometimes. Not sure why. I guess it has something to do with moving the ScriptingContainer to a field.

java.lang.NullPointerException
    at org.jruby.embed.internal.ThreadSafeLocalContextProvider.isRuntimeInitialized(ThreadSafeLocalContextProvider.java:73)
    at org.jruby.embed.ScriptingContainer.terminate(ScriptingContainer.java:1753)
    at org.ocpsoft.rewrite.transform.markup.JRubyTransformer.transform(JRubyTransformer.java:86)
    at org.ocpsoft.rewrite.transform.StringTransformer.transform(StringTransformer.java:51)
    at org.ocpsoft.rewrite.transform.PipelineContentInterceptor.transform(PipelineContentInterceptor.java:76)
    at org.ocpsoft.rewrite.transform.PipelineContentInterceptor.intercept(PipelineContentInterceptor.java:57)
    at org.ocpsoft.rewrite.servlet.impl.ResponseContentInterceptorChainImpl.proceed(ResponseContentInterceptorChainImpl.java:44)
    at org.ocpsoft.rewrite.servlet.impl.ResponseContentInterceptorChainImpl.begin(ResponseContentInterceptorChainImpl.java:59)
    at org.ocpsoft.rewrite.servlet.impl.HttpRewriteWrappedResponse.flushBufferedContent(HttpRewriteWrappedResponse.java:151)
    at org.ocpsoft.rewrite.servlet.impl.DefaultRewriteLifecycleListener.afterInboundLifecycle(DefaultRewriteLifecycleListener.java:56)
    at org.ocpsoft.rewrite.servlet.impl.DefaultRewriteLifecycleListener.afterInboundLifecycle(DefaultRewriteLifecycleListener.java:28)
    at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:198)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:123)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
    at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:171)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

Reading parameter values from other conditions doesn't work

I tried to write this rule with 2.0.0.Alpha4:

.addRule()
.when( Path.matches( "/styles/{name}.css" ).and( Resource.exists( "/styles/{name}.sass" ) ) )
.perform( Forward.to( "/styles/{name}.sass" ).and( Transform.with( Sass.class ) ) );

The rule will throw this error:

java.lang.IllegalStateException: Required parameter [name] value was null.
        at org.ocpsoft.rewrite.param.RegexParameterizedPatternBuilder.extractBoundValues(RegexParameterizedPatternBuilder.java:245)
        at org.ocpsoft.rewrite.param.RegexParameterizedPatternBuilder.build(RegexParameterizedPatternBuilder.java:130)
        at org.ocpsoft.rewrite.servlet.config.Resource.evaluateHttp(Resource.java:52)
        at org.ocpsoft.rewrite.servlet.config.HttpCondition.evaluate(HttpCondition.java:41)
        at org.ocpsoft.rewrite.config.And.evaluate(And.java:75)
        at org.ocpsoft.rewrite.config.RuleBuilder.evaluate(RuleBuilder.java:109)
        at org.ocpsoft.rewrite.config.And.evaluate(And.java:75)
        at org.ocpsoft.rewrite.config.RuleBuilder.evaluate(RuleBuilder.java:109)
        at org.ocpsoft.rewrite.servlet.impl.DefaultHttpRewriteProvider.rewriteHttp(DefaultHttpRewriteProvider.java:161)
        at org.ocpsoft.rewrite.servlet.http.HttpRewriteProvider.rewrite(HttpRewriteProvider.java:43)
        at org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:234)
        at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:186)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
        at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:123)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
        at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:171)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)

I'm not sure how to handle this. Is it something that should be supported?

java.lang.IllegalStateException: Committed

Hey Lincoln,

I'm opening a ticket for this because I think I know why this is happening. Actually it's a Rewrite bug. I'm trying to explain this in the following paragraphs.

First of all. This is the exception:

java.lang.IllegalStateException: Committed
    at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1066)
    at org.eclipse.jetty.server.Response.sendError(Response.java:274)
    at org.eclipse.jetty.server.Response.sendError(Response.java:376)
    at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:162)
    at org.eclipse.jetty.servlet.DefaultServlet.doGet(DefaultServlet.java:472)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        [...]
    at java.lang.Thread.run(Thread.java:662)

You can reproduce it by running the ExpressionLanguageTest in the JSF module. This test contains a simple configuration which simply forwards /name/{param} to /faces/expression-language.xhtml. I think I know what is going wrong here:

The request to /name/christian comes in and is processed by the RewriteFilter. The flow is set to Flow.FORWARD and the request is then forwarded to /faces/expression-language.xhtml. The forwarded request hits the RewriteFilter a second time and it seems like it is correctly processed there.

The problem occurs inside the JSF lifecycle. At some time the RewritePhaseListener kicks in to process PhaseOperations. At this point the following code is executed:

Lifecycle.proceed().perform(operation.getEvent(), operation.getContext());

Actually I'm not 100% sure what this codes does and why. But it sets the flow to PROCEED. The problems seems to be that the flow of the outer request (the original request) is modified and not the flow of the forwarded one.

Later the RewriteFilter of the outer request continues its work after the RequestDispatcher.forward() call finished. Now as the flow changed from FORWARD to PROCEED, it calls chain.doFilter() and the request is further processed by the servlet engine. As the URL doesn't match any servlet mapping the default servlet processes it. But the default servlet won't find any resource matching the URL and therefore tries to send a 404. But this fails as the forwarded request was already committed.

So I think this is the problem. This was really difficult to debug. I thought it would be better to open a ticket for this to hear your thought about this. :)

Allow rule subsets/aggregation in ConfigurationBuilder

ConfigurationBuilder.begin()

// These rules will only be evaluated if the Subset.when() condition evaluates to true. 
// Perhaps create a sub-Flow here?
.addRule(Subset.when(Condition...)
                      .defineRule()...perform()
                      .addRule()
                      .addRule()
                      .defineRule()...perform()
                      .addRule()
                      .addRule())

.addRule(Join.path("blah").to("blarg"));

JSESSIONID breaks Joins

I'm using this configuration with 2.0.0.Alpha4:

@Named
@ViewScoped
@Join(path = "/somepage", to = "/WEB-INF/pages/somepage.jsf")
public class SomePage implements Serializable {
  // ....
}

This URL works fine:

http://localhost:8080/myapp/somepage

But this one results in a 404:

http://localhost:8080/myapp/somepage;jsessionid=8970B4E77CAFE4390B0A2ED374C1815B

I think we should handle this somehow. Didn't we have some special handling for JSESSIONID in PrettyFaces too?

Expose Forward/Include request parameters in RewriteEvent API

During an include or forward, vital information gets stuffed into request parameters. It would be nice to be able to access this information from an injectable Java resource.

javax.servlet.forward.request_uri
javax.servlet.forward.context_path
javax.servlet.forward.servlet_path
javax.servlet.forward.path_info
javax.servlet.forward.query_string

javax.servlet.include.request_uri
javax.servlet.include.context_path
javax.servlet.include.servlet_path
javax.servlet.include.path_info
javax.servlet.include.query_string

Enable Unified parameter transforms/constraints/bindings.

Configuring parameters should be a global event for the rule.

           /**
            * Access http://{domain}.example.com:8080/context/literal and you should see a FileNotFoundException or
            * * 404 for "/{domain}.xhtml", where "{domain}" matches the sub-domain of example.com
            */
           .addRule(Join.path("/literal").to("/{domain}.xhtml")

                .where("domain").matches(..etc..) // == NPE

                    .when(Domain.matches("{domain}.example.com")));



  Join fixall = Join.path("/{page}").to("/{page}.xhtml").when(
           DispatchType.isRequest()
                    .andNot(Path.matches(".*javax.faces.resource.*"))
           );
  fixall.where("page").matches(".*"); // this does not apply to outbound

Configuration of invalid parameters is no longer an error scenario, but should throw an Exception

org.ocpsoft.rewrite.param.DefaultParameterStore:46

Else clause is activated when the parameter name is not valid... should not be set to default parameter... should throw exception.

   @Override
   public Configuration getConfiguration(ServletContext context)
   {
      return ConfigurationBuilder.begin()
               .addRule()
               .when(Direction.isInbound().and(Path.matches("/{path}")))
               .perform(Log.message(Level.INFO, "Client requested path: {path}"))
               .where("blah").matches(".*");
   }

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.