Skip to content

Conversation

prakashmurthy
Copy link
Contributor

Raise a RuntimeException with custom message when hash key contains space. Old behavior was { "New York"=>33, :Versailles => 3231 }.to_xml created an xml which was invalid.

@josevalim
Copy link
Contributor

Shouldn't we just dasherize the keys or something like that?

@tenderlove
Copy link
Member

@josevalim I agree. @prakashmurthy, can you change this to dasherize keys, and I'll apply?

@prakashmurthy
Copy link
Contributor Author

Since dasherize method only replaces '_' with '-', and does not do anything to spaces, we are thinking of using gsub(' ','-').Is this OK?

@prakashmurthy
Copy link
Contributor Author

Used gsub instead of _dasherize method as there is another issue with _dasherize method being broken. #450

@josevalim
Copy link
Contributor

Thanks @prakashmurthy! I have fixed the _dasherize method, do you think your pull request could be refactored then? As the default is to dasherize, I don't even think we need to do anything, just add your tests. Could you please check?

@prakashmurthy
Copy link
Contributor Author

Thanks @josevalim. Refactored the code; now the change includes only the tests. Let me know if anything else needs to be done.

tenderlove added a commit that referenced this pull request May 8, 2011
Fix for Lighthouse ticket # 6334 : to_xml should render valid xml or raise an error all the time
@tenderlove tenderlove merged commit a45f300 into rails:master May 8, 2011
matthewd pushed a commit that referenced this pull request Apr 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants