UI Performance Plugin

UI-Performance plugin: changes charset when bundling files

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: Grails-UI-Performance 1.0
  • Component/s: None
  • Labels:
    None
  • Environment:
    Windows Vista Home Premium 64-bit

Description

I have some Swedish messages in some of my JavaScript files, and as such they have Swedish characters. While I was branching them I managed to change the charset of the files somehow, so they weren't UTF-8. Easy enough to fix. However, after fixing them the error still occurred in the production environment.

After some tracking it turns out that the bundling process of the UI-performance plugin works with the system default character encoding. Non-bundled files are OK. The missing code is in the ResourceVersionHelper.groovy file on line 357 to 364.

private void concatenate(List files, String name, String subdir, String ext, File stagingDir) {
new File(stagingDir, "$subdir/${name}.$ext").withWriter { writer ->
files.each { file ->
writer.write new File(stagingDir, "$subdir/${file}.$ext").text
writer.write '\n'
}
}
}

Fixing it could be like this, but adding the charset as a parameter will allow for better configuration.

private void concatenate(List files, String name, String subdir, String ext, File stagingDir) {
new File(stagingDir, "$subdir/${name}.$ext").withWriter( "utf-8", { writer ->
files.each { file ->
writer.write new File(stagingDir, "$subdir/${file}.$ext").getText('utf-8')
writer.write '\n'
}
})
}

Activity

Hide
Morten Nielsen added a comment -

Let me know if you need help testing. Im using a modifed groovy file for now.

Show
Morten Nielsen added a comment - Let me know if you need help testing. Im using a modifed groovy file for now.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: