Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: znc/znc
base: dcf357b
...
head fork: znc/znc
compare: da0ba75
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
Commits on Aug 05, 2011
@psychon psychon Include zncconfig.h in all headers
The rule is that zncconfig.h must be the very same thing that is included. We
cheat and only include it in headers (so that modules dont have to have be
changed). However, it looks like some modules where missed.

This commit fixes test/ConfigTest which crashed if _GLIBCXX_DEBUG was enabled
(--enable-debug) because it didn't see this define before including a c++
header.

Signed-off-by: Uli Schlachter <psychon@znc.in>
8d17f50
@psychon psychon Fix module data for extra/ modules
No module in extra/ comes with any data currently, so this was tested by moving
perform to extra/. The install is untested.

Signed-off-by: Uli Schlachter <psychon@znc.in>
cb6798d
@psychon psychon Fix CString::Escape_n() and add some tests for it
This bug was originally reported by someone on irc, but sadly I forgot who it
was. Sorry!

Signed-off-by: Uli Schlachter <psychon@znc.in>
da0ba75
View
1  .gitignore
@@ -31,6 +31,7 @@ Makefile
/modules/*.pyc
/test/ConfigTest
+/test/EscapeTest
# Compiled Object files
*.o
View
1  Config.h
@@ -9,6 +9,7 @@
#ifndef CONFIG_H
#define CONFIG_H
+#include "zncconfig.h"
#include "ZNCString.h"
class CFile;
View
1  ExecSock.h
@@ -9,6 +9,7 @@
#ifndef EXEC_SOCK_H
#define EXEC_SOCK_H
+#include "zncconfig.h"
#include "Socket.h"
#include <signal.h>
View
2  Modules.cpp
@@ -1035,7 +1035,7 @@ CModules::ModDirList CModules::GetModDirs() {
// ./modules/extra
sDir = CZNC::Get().GetCurPath() + "/modules/extra/";
- ret.push(std::make_pair(sDir, sDir));
+ ret.push(std::make_pair(sDir, sDir + "data/"));
#endif
// ~/.znc/modules
View
1  ZNCDebug.h
@@ -9,6 +9,7 @@
#ifndef ZNCDEBUG_H
#define ZNCDEBUG_H
+#include "zncconfig.h"
#include <iostream>
using std::cout;
View
8 ZNCString.cpp
@@ -212,10 +212,10 @@ CString CString::Escape_n(EEscape eFrom, EEscape eTo) const {
}
if (ch == 0) {
- if (!strncasecmp((const char*) &pTmp, "lt", 2)) ch = '<';
- else if (!strncasecmp((const char*) &pTmp, "gt", 2)) ch = '>';
- else if (!strncasecmp((const char*) &pTmp, "quot", 4)) ch = '"';
- else if (!strncasecmp((const char*) &pTmp, "amp", 3)) ch = '&';
+ if (!strncasecmp((const char*) &pTmp, "&lt;", 2)) ch = '<';
+ else if (!strncasecmp((const char*) &pTmp, "&gt;", 2)) ch = '>';
+ else if (!strncasecmp((const char*) &pTmp, "&quot;", 4)) ch = '"';
+ else if (!strncasecmp((const char*) &pTmp, "&amp;", 3)) ch = '&';
}
if (ch > 0) {
View
2  modules/Makefile.in
@@ -107,6 +107,8 @@ create_install_dir:
install_datadir: create_install_dir
cp -R $(srcdir)/data $(DESTDIR)$(DATADIR)/modules
+ # Disabled for now since no module in extra has some data files
+ #cp -R $(srcdir)/extra/data $(DESTDIR)$(DATADIR)/modules
find $(DESTDIR)$(DATADIR)/modules -type d -exec chmod 0755 '{}' \;
find $(DESTDIR)$(DATADIR)/modules -type f -exec chmod 0644 '{}' \;
View
55 test/EscapeTest.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2004-2011 See the AUTHORS file for details.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include "ZNCString.h"
+#include "ZNCDebug.h"
+
+static int testEqual(const CString& a, const CString& b, const CString& what)
+{
+ if (a == b)
+ return 0;
+ std::cout << what << " failed for '" << b << "', result is '" << a << "'\n";
+ return 1;
+}
+
+static int testString(const CString& in, const CString& url,
+ const CString& html, const CString& sql) {
+ CString out;
+ int errors = 0;
+
+ // Encode, then decode again and check we still got the same string
+
+ out = in.Escape_n(CString::EASCII, CString::EURL);
+ errors += testEqual(out, url, "EURL encode");
+ out = out.Escape_n(CString::EURL, CString::EASCII);
+ errors += testEqual(out, in, "EURL decode");
+
+ out = in.Escape_n(CString::EASCII, CString::EHTML);
+ errors += testEqual(out, html, "EHTML encode");
+ out = out.Escape_n(CString::EHTML, CString::EASCII);
+ errors += testEqual(out, in, "EHTML decode");
+
+ out = in.Escape_n(CString::EASCII, CString::ESQL);
+ errors += testEqual(out, sql, "ESQL encode");
+ out = out.Escape_n(CString::ESQL, CString::EASCII);
+ errors += testEqual(out, in, "ESQL decode");
+
+ return errors;
+}
+
+int main() {
+ unsigned int failed = 0;
+
+ // input url html sql
+ failed += testString("abcdefg", "abcdefg", "abcdefg", "abcdefg");
+ failed += testString("\n\t\r", "%0A%09%0D", "\n\t\r", "\\n\\t\\r");
+ failed += testString("'\"", "%27%22", "'&quot;", "\\'\\\"");
+ failed += testString("&<>", "%26%3C%3E", "&amp;&lt;&gt;", "&<>");
+
+ return failed;
+}
View
8 test/Makefile.in
@@ -9,7 +9,7 @@ CXXFLAGS := @DEFS@ @CPPFLAGS@ @CXXFLAGS@ -I..
LDFLAGS := @LDFLAGS@
LIBS := @LIBS@
-TARGETS := ConfigTest
+TARGETS := ConfigTest EscapeTest
OBJS := $(addsuffix .o, $(TARGETS))
ZNC_OBJS := Config.o ZNCDebug.o FileUtils.o Utils.o ZNCString.o MD5.o SHA256.o
ZNC_OBJS := $(addprefix ../, $(ZNC_OBJS))
@@ -35,6 +35,10 @@ ConfigTest: ConfigTest.o
$(E) Linking $@...
$(Q)$(CXX) $(LDFLAGS) -o $@ $< $(ZNC_OBJS) $(LIBS)
+EscapeTest: EscapeTest.o
+ $(E) Linking $@...
+ $(Q)$(CXX) $(LDFLAGS) -o $@ $< $(ZNC_OBJS) $(LIBS)
+
%.o: %.cpp Makefile
@mkdir -p .depend
$(E) Building $@...
@@ -42,5 +46,5 @@ ConfigTest: ConfigTest.o
test: $(TARGETS)
for test in $(TARGETS) ; do \
- $$test || exit 1 ; \
+ ./$$test || exit 1 ; \
done

No commit comments for this range

Something went wrong with that request. Please try again.