summaryrefslogtreecommitdiffstats
path: root/src/text-context.cpp
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2008-08-08 02:47:03 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2008-08-08 02:47:03 +0000
commitda36561ee99fefeef01ad9ee411b7b8f511071bc (patch)
tree641b547085d956819d0364942575a2897f6aaeee /src/text-context.cpp
parentFix regression in object snapper which caused self-snapping (diff)
downloadinkscape-da36561ee99fefeef01ad9ee411b7b8f511071bc.tar.gz
inkscape-da36561ee99fefeef01ad9ee411b7b8f511071bc.zip
patch from bug 244940
(bzr r6588)
Diffstat (limited to 'src/text-context.cpp')
-rw-r--r--src/text-context.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/text-context.cpp b/src/text-context.cpp
index 0865e06cb..5e0e1ee8e 100644
--- a/src/text-context.cpp
+++ b/src/text-context.cpp
@@ -1322,10 +1322,36 @@ sp_text_paste_inline(SPEventContext *ec)
// there is an active text object in this context, or a new object was just created
Glib::RefPtr<Gtk::Clipboard> refClipboard = Gtk::Clipboard::get();
- Glib::ustring const text = refClipboard->wait_for_text();
-
- if (!text.empty()) {
-
+ Glib::ustring const clip_text = refClipboard->wait_for_text();
+
+ if (!clip_text.empty()) {
+ // Fix for 244940
+ // The XML standard defines the following as valid characters
+ // (Extensible Markup Language (XML) 1.0 (Fourth Edition) paragraph 2.2)
+ // char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ // Since what comes in off the paste buffer will go right into XML, clean
+ // the text here.
+ Glib::ustring text(clip_text);
+ Glib::ustring::iterator itr = text.begin();
+ gunichar paste_string_uchar;
+
+ while(itr != text.end())
+ {
+ paste_string_uchar = *itr;
+
+ // Make sure we don't have a control character. We should really check
+ // for the whole range above... Add the rest of the invalid cases from
+ // above if we find additional issues
+ if(paste_string_uchar >= 0x00000020 ||
+ paste_string_uchar == 0x00000009 ||
+ paste_string_uchar == 0x0000000A ||
+ paste_string_uchar == 0x0000000D) {
+ itr++;
+ } else {
+ itr = text.erase(itr);
+ }
+ }
+
if (!tc->text) { // create text if none (i.e. if nascent_object)
sp_text_context_setup_text(tc);
tc->nascent_object = 0; // we don't need it anymore, having created a real <text>