Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86692 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2013-11-13 16:51:25


Author: danieljames
Date: 2013-11-13 16:51:25 EST (Wed, 13 Nov 2013)
New Revision: 86692
URL: http://svn.boost.org/trac/boost/changeset/86692

Log:
Check that attribute values aren't empty.

Maybe I should also make the parser more lax.

Text files modified:
   trunk/tools/quickbook/src/actions.cpp | 28 ++++++++++++++++++++--------
   1 files changed, 20 insertions(+), 8 deletions(-)

Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp Wed Nov 13 16:51:05 2013 (r86691)
+++ trunk/tools/quickbook/src/actions.cpp 2013-11-13 16:51:25 EST (Wed, 13 Nov 2013) (r86692)
@@ -74,12 +74,28 @@
             return placeholder;
         }
 
+ std::string get_attribute_value(quickbook::state& state,
+ quickbook::value const& value)
+ {
+ std::string x = value.is_encoded() ?
+ value.get_encoded() : detail::to_s(value.get_quickbook());
+
+ if (x.empty()) {
+ detail::outerr(value.get_file(), value.get_position())
+ << "Empty attribute value."
+ << std::endl;
+ ++state.error_count;
+ x = "xxx";
+ }
+
+ return x;
+ }
+
         std::string validate_id(quickbook::state& state,
                 quickbook::value const& id_value)
         {
             bool valid = true;
- std::string id = id_value.is_encoded() ?
- id_value.get_encoded() : detail::to_s(id_value.get_quickbook());
+ std::string id = get_attribute_value(state, id_value);
 
             // Special case since I use dollar ids for id placeholders.
             if (id[0] == '$') { valid = false; id[0] = '_'; }
@@ -319,9 +335,7 @@
 
         state.phrase
             << "<phrase role=\"";
- // TODO: Validate role?
- detail::print_string(role.is_encoded() ?
- role.get_encoded() : detail::to_s(role.get_quickbook()),
+ detail::print_string(get_attribute_value(state, role),
                 state.phrase.get());
         state.phrase
             << "\">"
@@ -1554,9 +1568,7 @@
             dst = validate_id(state, dst_value);
         }
         else {
- dst = dst_value.is_encoded() ?
- dst_value.get_encoded() :
- detail::to_s(dst_value.get_quickbook());
+ dst = get_attribute_value(state, dst_value);
 
             // TODO: Might be better to have an error for some invalid urls.
             if (link.get_tag() == phrase_tags::url) {


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk