You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As specified in the Grails 3.3.8 documentation here, the HTML codec should come as standard, and thus should provide the encodeAsHTML method on all objects. However, I believe that for Grails 3.3.8, it is not the case.
I have created the following tests to verify that codecs work by default due to issues I am having in a project I am trying to port from Grails 2.5.6 to Grails 6.2.0. I am doing this porting in intermediate steps, so I am currently trying to port from Grails 2.5.6 to Grails 3.3.8.
I tried to create a blank project to see if the issue I was having with codecs was isolated to me, but I don't think it is. I feel that I am missing something.
Here are the tests, located in the file src/test/groovy/EncoderTestsSpec.groovy:
import spock.lang.Specification
class EncoderTestsSpec extends Specification {
def 'Ensure we can call encodeAsHTML successfully in our application'() {
expect:
'"<script>"'.encodeAsHTML() == '"<script>"'
}
def 'Ensure we can call encodeAsBase64 successfully in our application'() {
expect:
'"<script>"'.encodeAsBase64() == 'IjxzY3JpcHQ+Ig=='
}
def 'Ensure we can call encodeAsMD5 successfully in our application'() {
expect:
'"<script>"'.encodeAsMD5() == '94936c5d221680f28f4128694dfd5c3f'
}
}
I expect all of these tests to pass.
Actual Behaviour
The base64 and md5 tests pass but the html test does not. I get the following error in my test output:
Condition failed with Exception:
'"<script>"'.encodeAsHTML() == '"<script>"'
|
groovy.lang.MissingMethodException: No signature of method: java.lang.String.encodeAsHTML() is applicable for argument types: () values: []
Possible solutions: encodeAsHex(), encodeAsSHA1(), encodeAsMD5(), encodeAsSHA256()
at EncoderTestsSpec.Ensure we can call encodeAsHTML successfully in our application(ExampleSpec.groovy:8)
Caused by: groovy.lang.MissingMethodException: No signature of method: java.lang.String.encodeAsHTML() is applicable for argument types: () values: []
Possible solutions: encodeAsHex(), encodeAsSHA1(), encodeAsMD5(), encodeAsSHA256()
... 1 more
Steps To Reproduce
Using Grails 3.3.8, create a new app with the command grails create-app -features hibernate5 -profile web virtualhome
Add in the following tests in the file src/test/groovy/ExampleSpec.groovy.
Run the command grails test-app -unit to execute the tests
import spock.lang.Specification
class EncoderTestsSpec extends Specification {
def 'Ensure we can call encodeAsHTML successfully in our application'() {
expect:
'"<script>"'.encodeAsHTML() == '"<script>"'
}
def 'Ensure we can call encodeAsBase64 successfully in our application'() {
expect:
'"<script>"'.encodeAsBase64() == 'IjxzY3JpcHQ+Ig=='
}
def 'Ensure we can call encodeAsMD5 successfully in our application'() {
expect:
'"<script>"'.encodeAsMD5() == '94936c5d221680f28f4128694dfd5c3f'
}
}
Environment Information
I am using a Macbook air running MacOS Sonoma 14.6.1. I am running grails 3.3.8. The following commands are what I copy-paste to set up my environment:
The text was updated successfully, but these errors were encountered:
Razorfang
changed the title
encodeAsHTML is unavaibale by default in Grails 3.3.8 projects but other encoders are
encodeAsHTML is anavailable by default in Grails 3.3.8 projects but other encoders are
Sep 24, 2024
Expected Behavior
As specified in the Grails 3.3.8 documentation here, the HTML codec should come as standard, and thus should provide the encodeAsHTML method on all objects. However, I believe that for Grails 3.3.8, it is not the case.
I have created the following tests to verify that codecs work by default due to issues I am having in a project I am trying to port from Grails 2.5.6 to Grails 6.2.0. I am doing this porting in intermediate steps, so I am currently trying to port from Grails 2.5.6 to Grails 3.3.8.
I tried to create a blank project to see if the issue I was having with codecs was isolated to me, but I don't think it is. I feel that I am missing something.
Here are the tests, located in the file
src/test/groovy/EncoderTestsSpec.groovy
:I expect all of these tests to pass.
Actual Behaviour
The base64 and md5 tests pass but the html test does not. I get the following error in my test output:
Steps To Reproduce
grails create-app -features hibernate5 -profile web virtualhome
src/test/groovy/ExampleSpec.groovy
.grails test-app -unit
to execute the testsEnvironment Information
I am using a Macbook air running MacOS Sonoma 14.6.1. I am running grails 3.3.8. The following commands are what I copy-paste to set up my environment:
My application.yml file is unchanged from the default:
My build.gradle file is also completely unchanged:
Example Application
No response
Version
3.3.8
The text was updated successfully, but these errors were encountered: