Giter Site home page Giter Site logo

Comments (8)

timtebeek avatar timtebeek commented on June 2, 2024 1

Thanks again for the report @smurf667 ; you can try it out through our snapshot versions, before we release somewhere in the next two weeks.

from rewrite.

smurf667 avatar smurf667 commented on June 2, 2024 1

Thank you @timtebeek - I am very impressed with the handling of the issue and the speed of the fix. I tried the 8.12.0-SNAPSHOT, and it works for me. Good job, and thanks again!

from rewrite.

timtebeek avatar timtebeek commented on June 2, 2024

Thanks for providing context to the issue; indeed unfortunate that you have to deal with such escapes, and we have to handle that better.

from rewrite.

timtebeek avatar timtebeek commented on June 2, 2024

Exploring the issue here for a bit; your test indeed fails; this passes, despite the escape

@Test
void escapedAinArtifactId() {
    rewriteRun(
      pomXml(
        """
          <project>
            <groupId>com.mycompany.app</groupId>
            <artifactId>my-app</artifactId>
            <version>1</version>
            <dependencies>
              <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-&#0097;pi</artifactId>
                <version>2.0.9</version>
              </dependency>
            </dependencies>
          </project>
          """,
        spec -> spec.afterRecipe(pomXml -> {
            assertThat(pomXml.getMarkers().findFirst(MavenResolutionResult.class).orElseThrow()
              .getDependencies().get(Scope.Compile))
              .singleElement()
              .satisfies(dep -> assertThat(dep.getArtifactId()).isEqualTo("slf4j-api"));
        })
      )
    );
}

from rewrite.

timtebeek avatar timtebeek commented on June 2, 2024

And this indeed shows what you also found, that the artifactId contains an ArrayList instead of a regular value

@Test
void escapedAinArtifactIdVisited() {
    rewriteRun(
      spec -> spec.recipe(RewriteTest.toRecipe(() -> new XmlVisitor<>() {
          @Override
          public Xml visitTag(Xml.Tag tag, ExecutionContext ctx) {
              if (new XPathMatcher("/project/dependencies/dependency").matches(getCursor())) {
                  var child = tag.getChild("artifactId");
                  var childValue = tag.getChildValue("artifactId");
                  var children = tag.getChildren("artifactId");
                  System.out.println();
              }
              return super.visitTag(tag, ctx);
          }
      })),
      pomXml(
        """
          <project>
            <groupId>com.mycompany.app</groupId>
            <artifactId>my-app</artifactId>
            <version>1</version>
            <dependencies>
              <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-&#0097;pi</artifactId>
                <version>2.0.9</version>
              </dependency>
            </dependencies>
          </project>
          """
      )
    );
}

from rewrite.

knutwannheden avatar knutwannheden commented on June 2, 2024

@traceyyoshima It seems like the XML entity fix you made doesn't also extend to XML character references and needs a separate fix.

from rewrite.

timtebeek avatar timtebeek commented on June 2, 2024

I think I have a fix in

from rewrite.

timtebeek avatar timtebeek commented on June 2, 2024

Glad to hear that works and thanks for confirming here!

from rewrite.

Related Issues (20)

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.