-
-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2169 from sparklemotion/2168-active-support-test-…
…failure fix(cruby): SAX and Push parser error handling in the presence of foreign handlers
- Loading branch information
Showing
16 changed files
with
129 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <nokogiri.h> | ||
#include "libxml/xmlerror.h" | ||
|
||
static VALUE foreign_error_handler_block = Qnil; | ||
|
||
static void foreign_error_handler(void* user_data, xmlErrorPtr c_error) | ||
{ | ||
rb_funcall(foreign_error_handler_block, rb_intern("call"), 0); | ||
} | ||
|
||
/* | ||
* call-seq: | ||
* __foreign_error_handler { ... } -> nil | ||
* | ||
* Override libxml2's global error handlers to call the block. This method thus has very little | ||
* value except to test that Nokogiri is properly setting error handlers elsewhere in the code. See | ||
* test/helper.rb for how this is being used. | ||
*/ | ||
static VALUE | ||
rb_foreign_error_handler(VALUE klass) | ||
{ | ||
rb_need_block(); | ||
foreign_error_handler_block = rb_block_proc(); | ||
xmlSetStructuredErrorFunc(NULL, foreign_error_handler); | ||
return Qnil; | ||
} | ||
|
||
/* | ||
* Document-module: Nokogiri::Test | ||
* | ||
* The Nokogiri::Test module should only be used for testing Nokogiri. | ||
* Do NOT use this outside of the Nokogiri test suite. | ||
*/ | ||
void | ||
init_test_global_handlers() | ||
{ | ||
VALUE mNokogiri = rb_define_module("Nokogiri"); | ||
VALUE mNokogiriTest = rb_define_module_under(mNokogiri, "Test"); | ||
|
||
rb_define_singleton_method(mNokogiriTest, "__foreign_error_handler", rb_foreign_error_handler, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters