Revision: 7770
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=7770&view=rev
Author:   dnaber
Date:     2012-07-28 18:12:02 +0000 (Sat, 28 Jul 2012)
Log Message:
-----------
fix escaping: don't create HTML entities

Modified Paths:
--------------
    
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleEditorController.groovy

Modified: 
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleEditorController.groovy
===================================================================
--- 
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleEditorController.groovy
       2012-07-28 14:42:15 UTC (rev 7769)
+++ 
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleEditorController.groovy
       2012-07-28 18:12:02 UTC (rev 7770)
@@ -196,7 +196,7 @@
         } else {
             log.info("Create rule XML: okay")
             String message = getMessage()
-            String correctSentence = params.correctExample1.encodeAsHTML()
+            String correctSentence = encodeXml(params.correctExample1)
             Language language = getLanguage()
             String incorrectSentence = getIncorrectSentenceWithMarker(language)
             String name = params.name ? params.name : "Name of rule"
@@ -214,7 +214,7 @@
             StringBuilder sb = new StringBuilder(incorrectSentence)
             sb.insert(expectedRuleMatches.get(0).toPos, "</marker>")
             sb.insert(expectedRuleMatches.get(0).fromPos, "<marker>")
-            incorrectSentence = 
sb.toString().encodeAsHTML().replace("&lt;marker&gt;", 
"<marker>").replace("&lt;/marker&gt;", "</marker>")
+            incorrectSentence = 
encodeXml(sb.toString()).replace("&lt;marker&gt;", 
"<marker>").replace("&lt;/marker&gt;", "</marker>")
         } else {
             throw new Exception("Sorry, got ${expectedRuleMatches.size()} rule 
matches for the example sentence, " +
                     "expected exactly one. Sentence: '${incorrectSentence}', 
Rule matches: ${expectedRuleMatches}")
@@ -222,11 +222,15 @@
         return incorrectSentence
     }
 
+    private encodeXml(String s) {
+        return s.replace("<string>", "").replace("</string>", "")
+    }
+
     private String createXml(String name, String message, String 
incorrectSentence, String correctSentence) {
         Language lang = getLanguage()
         PatternRule patternRule = createPatternRule(lang)
         String ruleId = createRuleIdFromName(name)
-        String xml = """<rule id="${ruleId.encodeAsHTML()}" 
name="${name.encodeAsHTML()}">
+        String xml = """<rule id="${encodeXml(ruleId)}" 
name="${encodeXml(name)}">
     <pattern>\n"""
         for (element in patternRule.getElements()) {
             if (element.isRegularExpression()) {
@@ -248,7 +252,7 @@
     }
 
     private String getMessage() {
-        String message = params.message.encodeAsHTML()
+        String message = encodeXml(params.message)
         message = message.replaceAll("\"(.*?)\"", 
"<suggestion>\$1</suggestion>")
         message = message.replaceAll("&quot;(.*?)&quot;", 
"<suggestion>\$1</suggestion>")
         return message

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Languagetool-cvs mailing list
Languagetool-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/languagetool-cvs

Reply via email to