OSDN Git Service

Correct problem where the URL couldn't have a ' in the text.
authorRandy Baumgarte <randy@fbn.cx>
Wed, 29 Sep 2010 17:21:09 +0000 (13:21 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Fri, 1 Oct 2010 16:44:13 +0000 (12:44 -0400)
src/cx/fbn/nevernote/gui/BrowserWindow.java

index ac9bd98..68e881e 100644 (file)
@@ -37,6 +37,8 @@ import java.util.HashMap;
 import java.util.List;\r
 import java.util.Locale;\r
 \r
 import java.util.List;\r
 import java.util.Locale;\r
 \r
+import org.apache.commons.lang.StringUtils;\r
+\r
 import com.evernote.edam.limits.Constants;\r
 import com.evernote.edam.type.Data;\r
 import com.evernote.edam.type.Note;\r
 import com.evernote.edam.limits.Constants;\r
 import com.evernote.edam.type.Data;\r
 import com.evernote.edam.type.Note;\r
@@ -1235,8 +1237,9 @@ public class BrowserWindow extends QWidget {
                        String selectedText = browser.selectedText();\r
                        logger.log(logger.EXTREME, "Inserting link on text "+selectedText);\r
                        logger.log(logger.EXTREME, "URL Link " +dialog.getUrl().trim());\r
                        String selectedText = browser.selectedText();\r
                        logger.log(logger.EXTREME, "Inserting link on text "+selectedText);\r
                        logger.log(logger.EXTREME, "URL Link " +dialog.getUrl().trim());\r
-                       String url = "<a href=\"" +dialog.getUrl().trim()\r
-                                       +"\" title=" +dialog.getUrl().trim() \r
+                       String dUrl = StringUtils.replace(dialog.getUrl().trim(), "'", "\\'");\r
+                       String url = "<a href=\"" +dUrl\r
+                                       +"\" title=" +dUrl \r
                                        +" >"+selectedText +"</a>";\r
                        String script = "document.execCommand('insertHtml', false, '"+url+"');";\r
                        browser.page().mainFrame().evaluateJavaScript(script);\r
                                        +" >"+selectedText +"</a>";\r
                        String script = "document.execCommand('insertHtml', false, '"+url+"');";\r
                        browser.page().mainFrame().evaluateJavaScript(script);\r