Wicket
  1. Wicket
  2. WICKET-1139

Wicket html files do not have xml prolog

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.0-beta4
    • Fix Version/s: 1.3.0-rc2
    • Component/s: wicket
    • Labels:
      None
    • Environment:
      n/a

      Description

      We want to enforce all our pages to explicitly specify xml prolog in order to avoid troubles with encodings (unfortunately we are not ASCII-speaking). We want to do that by specifying invalid defaultMarkupEncoding. This way we will get exceptions for all htmls that didn't declare encoding. However it is not possible at the moment because many wicket built-in html files do not have xml prolog.

      Fix is very simple: just add <?xml version="1.0" encoding="UTF-8" ?> to your html files.

        Issue Links

          Activity

          Marat Radchenko created issue -
          Hide
          Martijn Dashorst added a comment -

          I think this has some adverse side effects for the rest of the world that dont' want your behavior. I think it triggers a different rendering engine in browsers, so we really don't want to force that onto our users.

          You can create your own servlet filter that prepends the response with this declaration if it is missing. No biggy IMO. If you want a more permanent solution, I suggest creating your own copy of Wicket with the markup files modified to your liking.

          Show
          Martijn Dashorst added a comment - I think this has some adverse side effects for the rest of the world that dont' want your behavior. I think it triggers a different rendering engine in browsers, so we really don't want to force that onto our users. You can create your own servlet filter that prepends the response with this declaration if it is missing. No biggy IMO. If you want a more permanent solution, I suggest creating your own copy of Wicket with the markup files modified to your liking.
          Hide
          Marat Radchenko added a comment - - edited

          Well, I'm not speaking about outputting xml prolog to users. I'm speaking about using it when loading markup files.

          Outputting xml prolog to users is handled by stripXmlDeclarationFromOutput in IMarkupSettings.

          Show
          Marat Radchenko added a comment - - edited Well, I'm not speaking about outputting xml prolog to users. I'm speaking about using it when loading markup files. Outputting xml prolog to users is handled by stripXmlDeclarationFromOutput in IMarkupSettings.
          Hide
          Johan Compagner added a comment -

          But are they all saved as utf-8?
          And do we have internally files that really need that encoding when loading?

          Show
          Johan Compagner added a comment - But are they all saved as utf-8? And do we have internally files that really need that encoding when loading?
          Hide
          Marat Radchenko added a comment -

          That was just an example. You should specify real file encoding. The thing is that it will be explicitly specified and wicket won't rely on system default charset when loading them.

          Show
          Marat Radchenko added a comment - That was just an example. You should specify real file encoding. The thing is that it will be explicitly specified and wicket won't rely on system default charset when loading them.
          Hide
          Johan Compagner added a comment -

          can we just add the UTF-8 encoding to all our files?
          Are they then saved as UTF-8 as well?
          Also if it is panel then we can do it. Because that part is just for loading. But if it are pages then it is not that easy because then we also have that in the resulting page as far as i know.

          Show
          Johan Compagner added a comment - can we just add the UTF-8 encoding to all our files? Are they then saved as UTF-8 as well? Also if it is panel then we can do it. Because that part is just for loading. But if it are pages then it is not that easy because then we also have that in the resulting page as far as i know.
          Johan Compagner made changes -
          Field Original Value New Value
          Fix Version/s 1.3.0-rc2 [ 12312513 ]
          Hide
          Marat Radchenko added a comment -

          Your files are ASCII-only and so they do not care a lot about exact encoding. You can specify UTF-8 or ISO 8859-1 (or some other because all encodings (as far as I know) have same byte numbers for ASCII symbols).

          Affected files (list may be incomplete):
          org/apache/wicket/markup/html/panel/FeedbackPanel.html
          org/apache/wicket/markup/html/panel/EmptyPanel.html
          org/apache/wicket/markup/html/pages/RedirectPage.html
          org/apache/wicket/markup/html/pages/PageExpiredErrorPage.html
          org/apache/wicket/markup/html/pages/InternalErrorPage.html
          org/apache/wicket/markup/html/pages/ExceptionErrorPage.html
          org/apache/wicket/markup/html/pages/AccessDeniedPage.html

          Show
          Marat Radchenko added a comment - Your files are ASCII-only and so they do not care a lot about exact encoding. You can specify UTF-8 or ISO 8859-1 (or some other because all encodings (as far as I know) have same byte numbers for ASCII symbols). Affected files (list may be incomplete): org/apache/wicket/markup/html/panel/FeedbackPanel.html org/apache/wicket/markup/html/panel/EmptyPanel.html org/apache/wicket/markup/html/pages/RedirectPage.html org/apache/wicket/markup/html/pages/PageExpiredErrorPage.html org/apache/wicket/markup/html/pages/InternalErrorPage.html org/apache/wicket/markup/html/pages/ExceptionErrorPage.html org/apache/wicket/markup/html/pages/AccessDeniedPage.html
          Hide
          Juergen Donnerstag added a comment -

          the encoding given in the markup file is always only used for loading the data and will never be forwarded to the client browser. We use Settings (and configureResponse) to determine what goes into the response and that setting is applied to all responses (except you define different in configureResponse).

          In my opinion this is not a valid request. Our internal markup files do not contain any none-ascii characters. If a user wants to supersede with an extended subclass and add <?xml ..> to the his own markup than that is perfectly fine. As mentioned above we are using it for loading only and it is perfectly fine to mix and match different encoding. No <?xml ..> means that the JVM / OS default will be used.

          Show
          Juergen Donnerstag added a comment - the encoding given in the markup file is always only used for loading the data and will never be forwarded to the client browser. We use Settings (and configureResponse) to determine what goes into the response and that setting is applied to all responses (except you define different in configureResponse). In my opinion this is not a valid request. Our internal markup files do not contain any none-ascii characters. If a user wants to supersede with an extended subclass and add <?xml ..> to the his own markup than that is perfectly fine. As mentioned above we are using it for loading only and it is perfectly fine to mix and match different encoding. No <?xml ..> means that the JVM / OS default will be used.
          Hide
          Marat Radchenko added a comment -

          Hi, Juergen. I do not ask to specify any encoding to be sent to client. And I do not ask to specify default encoding for parsing of all markup files or for client output. I just ask to explicitly specify any encoding that you consider appropriate for Wicket built-in html files. It doesn't have to be UTF-8. It can have absolutely any value that will allow correct file reading.

          I know that this encoding is used for loading only. The point is that we want to force all html files in our application to explicitly specify encoding (because platform default may [an will] be inacceptable). And in current situation we have to duplicate all Wicket htmls with addition of xml prolog.

          As additional argument, you cannot be sure that all current and future encodings that can possibly be set as platform default will correctly load your html files. So explicit specifying will protect you against possible environment-specific errors.

          Show
          Marat Radchenko added a comment - Hi, Juergen. I do not ask to specify any encoding to be sent to client. And I do not ask to specify default encoding for parsing of all markup files or for client output. I just ask to explicitly specify any encoding that you consider appropriate for Wicket built-in html files. It doesn't have to be UTF-8. It can have absolutely any value that will allow correct file reading. I know that this encoding is used for loading only. The point is that we want to force all html files in our application to explicitly specify encoding (because platform default may [an will] be inacceptable). And in current situation we have to duplicate all Wicket htmls with addition of xml prolog. As additional argument, you cannot be sure that all current and future encodings that can possibly be set as platform default will correctly load your html files. So explicit specifying will protect you against possible environment-specific errors.
          Hide
          Johan Compagner added a comment -

          yeah i see your point, we have to fix this and set some encoding in the file so that the readers uses that.
          because platform specific can be any thing and if we save it in 8859 then another system can be on a completely different encoding and tries to load those files with something else.

          i just have to check if we change the page (ExceptionErrorPage) then we have to strip that again from the real output because thats by default always utf-8. But maybe we already do that

          Show
          Johan Compagner added a comment - yeah i see your point, we have to fix this and set some encoding in the file so that the readers uses that. because platform specific can be any thing and if we save it in 8859 then another system can be on a completely different encoding and tries to load those files with something else. i just have to check if we change the page (ExceptionErrorPage) then we have to strip that again from the real output because thats by default always utf-8. But maybe we already do that
          Hide
          Juergen Donnerstag added a comment -
          • fixed all wicket core markup files
          • IMarkupSettings.set/getThrowExceptionOnXmlDeclarationMissing() (disabled by default)
          Show
          Juergen Donnerstag added a comment - fixed all wicket core markup files IMarkupSettings.set/getThrowExceptionOnXmlDeclarationMissing() (disabled by default)
          Juergen Donnerstag made changes -
          Resolution Fixed [ 1 ]
          Assignee Juergen Donnerstag [ jdonnerstag ]
          Status Open [ 1 ] Resolved [ 5 ]
          Hide
          Marat Radchenko added a comment -

          Wow. Thanks

          Show
          Marat Radchenko added a comment - Wow. Thanks
          Igor Vaynberg made changes -
          Link This issue relates to WICKET-1224 [ WICKET-1224 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          22d 22h 9m 1 Juergen Donnerstag 02/Dec/07 09:56

            People

            • Assignee:
              Juergen Donnerstag
              Reporter:
              Marat Radchenko
            • Votes:
              2 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development