Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URLs with query parameters in generated Javadoc should use &, not & #7

Closed
FroMage opened this issue Sep 15, 2011 · 5 comments
Closed
Labels
Milestone

Comments

@FroMage
Copy link
Owner

FroMage commented Sep 15, 2011

Reported by MatrixFrog, Aug 2, 2011
What steps will reproduce the problem?

  1. Create a JAX-RS method that takes multiple query parameters, one of which is "regex", like:

@path("resource")
@get
public void getResource(@QueryParam("status") String status, @QueryParam("regex") String regex) {...}

  1. Generate JAX-RS documentation for the method.

What is the expected output? What do you see instead?
You expect the output to include something like "GET /resource?status=�&regex=�" but instead you see "GET /resource?status=�®ex=�"

What version of the product are you using? On what operating system?
0.9.0, Windows 7

Please provide any additional information below.
When you "view source" on the page, you see "GET /resource?status=�&regex=�" as expected. The browser (I'm using the Aurora build of Firefox, but I assume most other browsers will do the same thing -- I can try them out if you want) sees "&reg" and it assumes the author meant to write "®" which is the HTML entity for ®, so it displays ®. I would argue the browser is technically wrong, but if the HTML contained "GET /resource?status=�&regex=�" then there would be no ambiguity.

Alternatively, maybe using a particular HTML doctype declaration or something like that, will tell the browser not to be "clever" and only interpret entities that are written properly?

@FroMage
Copy link
Owner Author

FroMage commented Sep 15, 2011

comment Comment 1 by MatrixFrog, Aug 3, 2011
I don't know much about Doclet writing, but I figured the simplest way to fix this is:

  1. Find all the places in the code where a "&" is added.
  2. Replace each of them with "&"

And I haven't done extensive testing but it seems to work. This patch was created against the 0.9.0 tag.

@FroMage
Copy link
Owner Author

FroMage commented Sep 15, 2011

Index: doclets/src/main/java/com/lunatech/doclets/jax/jaxrs/model/ResourceMethod.java

--- doclets/src/main/java/com/lunatech/doclets/jax/jaxrs/model/ResourceMethod.java (revision 138)
+++ doclets/src/main/java/com/lunatech/doclets/jax/jaxrs/model/ResourceMethod.java (working copy)
@@ -438,7 +438,7 @@
boolean first = true;
for (String name : queryParameters.keySet()) {
if (!first)

  •      strbuf.append("&");
    
  •      strbuf.append("&");
     strbuf.append(name);
     strbuf.append("=…");
     first = false;
    

    Index: doclets/src/main/java/com/lunatech/doclets/jax/jaxrs/writers/MethodWriter.java

    --- doclets/src/main/java/com/lunatech/doclets/jax/jaxrs/writers/MethodWriter.java (revision 138)
    +++ doclets/src/main/java/com/lunatech/doclets/jax/jaxrs/writers/MethodWriter.java (working copy)
    @@ -386,7 +386,7 @@
    boolean first = true;
    for (String name : queryParameters.keySet()) {
    if (!first)
  •      print("&");
    
  •      print("&");
     print(name);
     print("=…");
     first = false;
    
    @@ -416,7 +416,7 @@
    boolean first = true;
    for (String name : formParameters.keySet()) {
    if (!first)
  •      print("&");
    
  •      print("&");
     print(name);
     print("=…");
     first = false;
    

@FroMage
Copy link
Owner Author

FroMage commented Sep 15, 2011

comment Comment 2 by project member stephane.epardaud, Aug 15, 2011
Right, that's a bug. Thanks a lot for the patch I'll try it out ASAP.

MatrixFrog added a commit to MatrixFrog/jax-doclets that referenced this issue Sep 15, 2011
@MatrixFrog
Copy link
Contributor

(10453ca is the same patch I posted on Google Code, just wanted to make it available as an actual git commit.)

@FroMage
Copy link
Owner Author

FroMage commented Jan 2, 2012

Fixed now, thanks a lot.

@FroMage FroMage closed this as completed Jan 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants