[sword-svn] r2250 - in trunk/src: modules/filters utilfuns
scribe at crosswire.org
scribe at crosswire.org
Fri Feb 13 22:48:58 MST 2009
Author: scribe
Date: 2009-02-13 22:48:58 -0700 (Fri, 13 Feb 2009)
New Revision: 2250
Modified:
trunk/src/modules/filters/osishtmlhref.cpp
trunk/src/utilfuns/url.cpp
Log:
Fixed a horrible initialization issue in URL encode
Modified: trunk/src/modules/filters/osishtmlhref.cpp
===================================================================
--- trunk/src/modules/filters/osishtmlhref.cpp 2009-02-14 04:02:25 UTC (rev 2249)
+++ trunk/src/modules/filters/osishtmlhref.cpp 2009-02-14 05:48:58 UTC (rev 2250)
@@ -119,7 +119,7 @@
if (!suspendTextPassThru) {
buf.appendFormatted("<small><em><<a href=\"passagestudy.jsp?action=showStrongs&type=%s&value=%s\">%s</a>></em></small>",
(gh.length()) ? gh.c_str() : "",
- URL::encode(val2).c_str(),
+ URL::encode(val2).c_str(),
val2);
}
//}
Modified: trunk/src/utilfuns/url.cpp
===================================================================
--- trunk/src/utilfuns/url.cpp 2009-02-14 04:02:25 UTC (rev 2249)
+++ trunk/src/utilfuns/url.cpp 2009-02-14 05:48:58 UTC (rev 2250)
@@ -31,6 +31,27 @@
SWORD_NAMESPACE_START
+namespace {
+ typedef std::map< unsigned char, SWBuf > DataMap;
+ DataMap m;
+ static class __init {
+ public:
+ __init() {
+ for (unsigned short int c = 32; c <= 255; ++c) { //first set all encoding chars
+ if ( (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || strchr("-_.!~*'()", c)) {
+ continue; //we don't need an encoding for this char
+ }
+
+ SWBuf buf;
+ buf.setFormatted("%%%-.2X", c);
+ m[c] = buf;
+ }
+ //the special encodings for certain chars
+ m[' '] = '+';
+ }
+ } ___init;
+}
+
/**
* Constructors/Destructors
*/
@@ -197,24 +218,11 @@
}
}
+
const SWBuf URL::encode(const char *urlText) {
/*static*/ SWBuf url;
url = urlText;
- typedef std::map< unsigned char, SWBuf > DataMap;
- DataMap m;
- for (unsigned short int c = 32; c <= 255; ++c) { //first set all encoding chars
- if ( (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || strchr("-_.!~*'()", c)) {
- continue; //we don't need an encoding for this char
- }
-
- SWBuf buf;
- buf.setFormatted("%%%-.2X", c);
- m[c] = buf;
- }
- //the special encodings for certain chars
- m[' '] = '+';
-
SWBuf buf;
const int length = url.length();
for (int i = 0; i < length; i++) { //fill "buf"
More information about the sword-cvs
mailing list